仅当我使用 eclipse 时,我的应用程序前端在使用 intellij 时不会打开

问题描述 投票:0回答:1

我有一个已迁移到 SpringBoot 的遗留应用程序,当我通过 Eclipse 运行它而不配置任何不同的东西时,它会运行,当我访问我的 http://localhost:8080 时,它会正常打开,但当我通过 IntelliJ 运行它时,它不会打开前端并没有日志中的错误。调用端点时,后端可以工作,但前端不能工作。 HTML所在的结构是这个 src/main/webapp/pages 我在属性中尝试了这个配置

spring.mvc.static-path-pattern=/pages/**
spring.resources.static-locations=classpath:/webapp/pages/,file:src/main/webapp/pages/

没有成功。 我尝试创建一个配置类,但也没有成功。 有谁知道我可以尝试的另一条路吗?

java spring spring-boot spring-mvc
1个回答
0
投票
It seems like there might be a configuration issue with IntelliJ that's causing your frontend not to load. Here are a few steps you can try to resolve the issue:

 **1. Mark src/main/webapp as a Resource Folder in IntelliJ:**
Right-click on src/main/webapp in the Project view.
Select Mark Directory as > Resources Root.
**2.Verify Maven or Gradle Configuration:**
Make sure your pom.xml or build.gradle includes the web resources directory. For Maven, add the following to your pom.xml:
<build>
    <resources>
        <resource>
            <directory>src/main/webapp</directory>
            <includes>
                <include>**/*</include>
            </includes>
        </resource>
    </resources>
</build>
**3. Check Spring Boot Configuration:**
Verify your application.properties configuration. Ensure it points to the correct paths:
spring.mvc.static-path-pattern=/pages/**
spring.resources.static-locations=classpath:/webapp/pages/,file:src/main/webapp/pages/
**4. Invalidate Caches and Restart IntelliJ:**
Go to File > Invalidate Caches / Restart > Invalidate and Restart.
© www.soinside.com 2019 - 2024. All rights reserved.