springboot打war包遇到的404问题

一般来说springboot都打成jar包简单方便,java -jar就可以发布启动,但是也有打成war包然后用外置tomcat发布的时候.

看了一些贴说添加如下依赖,实测不行,这里用的是 maven3.6.1 tomcat8.5.x springboot2.1.x

<!--添加tomcat-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

添加了上述依赖会报出

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-tomcat:jar is missing. @ line 27, column 15
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.shareworx:XXXXXX-Main:3.0.0 (G:\Project\DMS\XXXXXX\pom.xml) has 1 error
[ERROR]     'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-tomcat:jar is missing. @ line 27, column 15
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

然后试了跟他们的贴,不加这些依赖pom,仅仅修改启动类继承SpringBootServletInitializer并重写方法则编译成功,

我遇到的问题是,外置tomcat需要加入工程的文件夹名字,但是忘记加了,加了即访问到不再404

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容