赞
踩
- @SpringBootApplication
- public class MainApplication extends SpringBootServletInitializer {
-
- @Override
- protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
- return builder.sources(MainApplication.class);
- }
-
- public static void main(String[] args) {
- SpringApplication.run(MainApplication.class, args);
- }
- }
- <packaging>war</packaging>
- <properties>
- <java.version>tomcatJDK版本</java.version>
- </properties>
- <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>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>4.0.1</version>
- <scope>provided</scope>
- </dependency>
具体方法:
将下载的zip文件解压,进入解压文件的lib目录下
将idea打包好的war包复制过来,打开命令行
执行命令生成二次编译war包
java -jar jakartaee-migration-1.0.7.jar -zipInMemory wuyou-backend-0.0.1-SNAPSHOT.war chuangxin.war
将二次编译的war包放到tomcat路径下webapps目录下
修改tomcat下conf目录下的server.xml,catalina.properties,logging.properties文件配置
tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*.jar
<Context path="" docBase="war包所在位置" debug="0" reloadable="true" />
不同的前端架构生成的位置或文件名不同 详见架构官方文档
将静态文件放到tomcat下webapps目录
添加WEB-INF文件夹,文件内新建web.xml文件
web.xml内容
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
- http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
- version="3.1" metadata-complete="true">
- <display-name>Router for Tomcat</display-name>
- <error-page>
- <error-code>404</error-code>
- <location>/index.html</location>
- </error-page>
- </web-app>
(检查任务管理器中的tomcat服务是否关闭)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。