springBoot項目啟動類啟動無法訪問。
網上也查了一些資料,我這里總結。下不來虛的,也不廢話。
解決辦法:
1、若是maven項目,則找到右邊Maven Projects --->Plugins--->run(利用maven啟動)則可以加載到webapp資源
2、上面方法治標不治本。在項目的pom文件中添加<bulid>標簽標注路徑即可,pom.xml后部分代碼如下:
刷新maven加載,重啟項目。若還是無法訪問,重新導入項目
<dependencies>
xxxxxxxxxxxx
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
<finalName>robot</finalName>
<resources>
<resource>
<directory>src/main/webapp</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
</project>
想要在服務器發布打成jar包。發現正常啟動,無法訪問jsp資源 看下片博客
