spring boot web项目部署到外部tomcat
来源:互联网 发布:mac与windows共享文件 编辑:程序博客网 时间:2024/06/06 06:54
spring boot项目打成war包部署到外部tomcat
部署到外部tomcat 在打包之前需要先将spring boot内置的tomcat去除
去除内置tomcat有2种
1:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions></dependency>
2: 不使用第一种可直接在pom文件中直接添加tomcat的信息,但是需要将使用的范围定义成provided
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
有的项目可能需要自己添加java-servlete-api的信息
去除tomcat相关jar之后,需要新建一个类实现SpringBootServletInitializer 重写configure方法
@SpringBootApplicationpublic class ServleteInitService extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure( SpringApplicationBuilder application) { //App类为springboot 项目的启动类 return application.sources(App.class); }
打包如下:
myeclipse maven 命令 package 或者install 都能打包,区别在与package 会在target目录下生产打包文件,install会在本地maven库中生产打包文件
将生成的war 放到tomcat webapps目录下,一般将XXX.war改名成ROOT.war
可能遇到的问题:
1:如果打的war 部署到tomcat7或者版本更低的tomcat中 可能会导致项目无法启动,网上有人说可以spring boot默认支持的是8 所以需要修改pom中tomcat的版本,添加
<properties> <tomcat.version>7.0.69</tomcat.version></properties>但是 我这边配置了之后并不好用,所以无奈只能换成tomcat8 之后启动成功:
2:有时候打war时 可能自己的一些静态文件未能打到war中,导致访问页面时出现找不到js,css等 正常情况下默认的是打包java/main/resources 文件下所有的文件,如果未能打到war中 可尝试使用<resources>标签指定添加文件
阅读全文
1 0
- spring boot web项目部署到外部tomcat
- Spring Boot项目部署到外部Tomcat服务器
- spring-boot项目的创建以及部署到外部tomcat的方法
- spring boot发布war包,部署到外部tomcat服务器
- spring-boot项目在外部tomcat环境下部署
- spring-boot项目在外部tomcat环境下部署
- spring-boot项目在外部tomcat环境下部署
- spring-boot项目在外部tomcat环境下部署
- spring-boot项目在外部tomcat环境下部署
- spring-boot项目在外部tomcat环境下部署
- spring-boot项目在外部tomcat环境下部署
- 如何将Spring Boot项目打包部署到外部Tomca
- 把spring-boot项目部署到tomcat容器中
- spring-boot项目部署到tomcat容器中
- spring boot开发项目,部署到tomcat,启动报错
- 把spring-boot项目部署到tomcat容器中
- 把spring-boot项目部署到tomcat容器中
- 把spring-boot项目部署到tomcat容器中
- pygame入门小游戏(外星人入侵(8) )
- BZOJ 1208: [HNOI2004]宠物收养所
- 【考研】第十三周总结
- UML-用例、类图、类图之间的关系详解
- 享元模式
- spring boot web项目部署到外部tomcat
- Sublime Text3必备插件:SQL格式化工具(SqlBeautifier)
- 11.26补坑
- python3版本中的urllib
- java
- python 实现9宫格
- 让OpenCV2.4.9支持虚拟环境python3.5
- 项目管理--项目与项目管理
- springboot整合redis