美文网首页
springboot+gradle打成war发布到tomcat访

springboot+gradle打成war发布到tomcat访

作者: 宽宽侠 | 来源:发表于2018-09-20 11:13 被阅读0次

通常springboot项目有两种发布方式一种直接打包成jar在服务器直接运行,一种打成war包,放在tomcat下运行

作者在使用第二种方式时出现请求访问404的错误,大多数项目都是maven构建的,今天告诉大家gradle项目的解决方法

1.添加jar包

compilegroup :'org.springframework.boot',name:'spring-boot-legacy',version:'1.1.0.RELEASE'

providedCompilegroup:"org.springframework.boot",name:'spring-boot-starter-tomcat'

2.启动类添加

public class Applicationextends SpringBootServletInitializer{

public static void main(String args[]){

SpringApplication.run(Application.class, args);

}

@Override

    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

return application.sources(Application.class);

}

}

之后发布到tomcat下就可以正常访问了

相关文章

网友评论

      本文标题:springboot+gradle打成war发布到tomcat访

      本文链接:https://www.haomeiwen.com/subject/mlvgnftx.html