由于某些缘故公司的产品需要升级但并不希望花费大量时间重写前端代码原来的就不是前后分离的。所以虽然spring和springboot都升级为最新的版本但是依然还是需要支持jsp并继续用打包为war。本文中的例子百分百可以执行。一、概述升级的理由java1.8已经用得太久了就快不是长期优先支持的。毕竟1.8已经用了快10年了该抛弃了java17对于性能的提升是明显的至少有关资料是这么说的其次是被优先支持的有关三方技术也渐渐转向jdk17了例如VSCODE,KAFKA。eclise,sts也不再优先支持1.8团队需要升级技术不能老是在1.8中打转spring5.x已经用太久了而且有不少缺点原来的诸多配置需要多个xml文件有点小繁琐。其它理由老版本的产品依然继续支持保持war包理由每次更新的时候可能就是替换几个class和前端页面所以没有必要每次拷贝几百M的可执行代码可以更容易调整tomcat的配置把tomcat的配置从代码中脱离出来。保持JSP的理由暂时不想花费大量时间更新前端页面前端代码量比较大jsp没有什么大毛病虽然spring并不是很推荐它。但spring最新版本以及tomcat最新版本依然支持着。jsp技术某种意义上还是比较节约成本的。本文涉及到几个知识点servlet动态web项目二、搭建环境工具和环境操作系统windows 11 家庭版ide使用sts即可。本人使用的是Version: 4.14.1.RELEASE版本。容器tomcat使用最新的10.0.22jdk-17jquery-3.6.0本文的例子就是为了升级做准备的看是否可以比较容易地实现。大体步骤如下使用sts,选择spring starter project ,之后选择有关组件和选项。其中打包的选项选择warjava选择17。注意java8依然可以支持修改pom.xml-支持jsp和war包修改启动代码不修改也可以2.1使用spring starter project创建工程如果不想使用sts,仅仅是想看看有关配置可以通过https://start.spring.io/在线生成示例。以下几个图分别是目录结构图项目配置信息图。2.1.1目录结构图修改后的启动代码原来例子是两个类现在合并为一个不合并也可以package com.hc.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; SpringBootApplication public class SpringbootJspApplication extends SpringBootServletInitializer { Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(SpringbootJspApplication.class); } public static void main(String[] args) { SpringApplication.run(SpringbootJspApplication.class, args); } }这里最关键的是 SpringBootServletInitializer 。2.1.2项目配置信息-部署这里的关键是 src/main/webapp目录会映射到/这个src/main/webapp就是用于存放前端代码的。当然你要愿意修改为webContent,myhtml之类都可以只要做好部署映射即可。其它build pathjava compiler略过。2.1.3项目配置信息-project facets注意”dynamic web module不要选择太老的选择5.0即可。这个dynamic web mouule 5.0“意味着可以支持2.1.4项目配置信息-配置web上下文首先打开servers视图然后添加tomcat10,之后就可以设置上下文点击“edit”可以设置上下文。根据项目配置不同和sts的配置不同有的时候也可以在项目设置页面中直接设置上下文。2.2修改pom.xml这里是关键以下是本例的pom.xml的内容?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd modelVersion4.0.0/modelVersion parent groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-parent/artifactId version3.0.0-SNAPSHOT/version relativePath/ !-- lookup parent from repository -- /parent groupIdcom.hc.demo/groupId artifactIdspringjsp/artifactId version0.0.1-SNAPSHOT/version packagingwar/packaging namespringjsp/name descriptionDemo project for Spring boot and jsp and war/description properties java.version17/java.version /properties dependencies dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-jdbc/artifactId /dependency dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-web/artifactId exclusions exclusion groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-tomcat/artifactId /exclusion /exclusions /dependency dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-devtools/artifactId scoperuntime/scope optionaltrue/optional /dependency dependency groupIdmysql/groupId artifactIdmysql-connector-java/artifactId scoperuntime/scope /dependency !-- 以下1~4是为了支持jsp -- !-- 1添加servlet依赖模块 -- dependency groupIdorg.apache.tomcat/groupId artifactIdtomcat-servlet-api/artifactId version10.0.22/version /dependency !-- 2添加jstl标签库依赖模块 -- dependency groupIdjavax.servlet/groupId artifactIdjstl/artifactId /dependency !--3添加tomcat依赖模块.-- dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-tomcat/artifactId /dependency !-- 4使用jsp引擎springboot内置tomcat没有此依赖 -- dependency groupIdorg.apache.tomcat.embed/groupId artifactIdtomcat-embed-jasper/artifactId scopecompile/scope /dependency dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-test/artifactId scopetest/scope /dependency /dependencies build plugins plugin groupIdorg.springframework.boot/groupId artifactIdspring-boot-maven-plugin/artifactId /plugin !-- 配置war包插件 -- plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-war-plugin/artifactId configuration warSourceExcludessrc/main/resources/**/warSourceExcludes warNamespringjsp/warName failOnMissingWebXmlfalse/failOnMissingWebXml /configuration /plugin /plugins /build repositories repository idspring-milestones/id nameSpring Milestones/name urlhttps://repo.spring.io/milestone/url snapshots enabledfalse/enabled /snapshots /repository repository idspring-snapshots/id nameSpring Snapshots/name urlhttps://repo.spring.io/snapshot/url releases enabledfalse/enabled /releases /repository /repositories pluginRepositories pluginRepository idspring-milestones/id nameSpring Milestones/name urlhttps://repo.spring.io/milestone/url snapshots enabledfalse/enabled /snapshots /pluginRepository pluginRepository idspring-snapshots/id nameSpring Snapshots/name urlhttps://repo.spring.io/snapshot/url releases enabledfalse/enabled /releases /pluginRepository /pluginRepositories /project主要是两个地方要修改配置jsp配置war插件以上两个修改分类如以下两个地方2.2.1配置jsp!-- 以下1~4是为了支持jsp -- !-- 1添加servlet依赖模块 -- dependency groupIdorg.apache.tomcat/groupId artifactIdtomcat-servlet-api/artifactId version10.0.22/version /dependency !-- 2添加jstl标签库依赖模块 -- dependency groupIdjavax.servlet/groupId artifactIdjstl/artifactId /dependency !--3添加tomcat依赖模块.-- dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-tomcat/artifactId /dependency !-- 4使用jsp引擎springboot内置tomcat没有此依赖 -- dependency groupIdorg.apache.tomcat.embed/groupId artifactIdtomcat-embed-jasper/artifactId scopecompile/scope /dependency此外因为这里引入了spring-boot-starter-tomcat,所以需要把它从“spring-boot-starter-web”移除掉具体见完整pom.xml。2.2.2配置war插件build plugins plugin groupIdorg.springframework.boot/groupId artifactIdspring-boot-maven-plugin/artifactId /plugin plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-war-plugin/artifactId configuration warSourceExcludessrc/main/resources/**/warSourceExcludes warNamespringjsp/warName failOnMissingWebXmlfalse/failOnMissingWebXml /configuration /plugin /plugins /build三、编写测试代码3.1编写过滤器具体过程略一些列出过滤器代码package com.hc.demo.config.filter; import java.io.IOException; import org.springframework.web.filter.OncePerRequestFilter; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; public class MyFilter extends OncePerRequestFilter { Override public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { HttpServletRequest request2 (HttpServletRequest) request; String orgin request2.getHeader(origin); HttpServletResponse res (HttpServletResponse) response; res.addHeader(Access-Control-Allow-Origin, orgin); res.addHeader(Access-Control-Allow-Methods, *); res.addHeader(Access-Control-Allow-Headers, content-type); String urlrequest.getRequestURI().toString(); System.out.println(url); FilterRequest req new FilterRequest(request); filterChain.doFilter(req, response); } }注1.红色部分代码是为了便于观察过滤器是否生效。2.在jdk17中“servlet”的顶级包名以“jakarta开头这是一个很大的区别。3.2编写一个接口具体过程略先列出控制器代码package com.hc.demo.student.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.hc.demo.student.service.StudentService; Controller RequestMapping(value /student) public class StudentController { Autowired private StudentService studentService; RequestMapping(value list) ResponseBody public Object list() { return studentService.queryAll(); } }3.3编写一个jsp页面% page languagejava contentTypetext/html; charsetUTF-8 pageEncodingUTF-8% !DOCTYPE html html head meta charsetUTF-8 titlejsp测试/title /head style html, body { width: 100%; height: 100%; } .jsp-example { display: flex; color: red; font-size: 32px; height: 20%; margin-top: 10%; margin-bottom:4px; line-height: 50%; text-align: center; background-color: yellow; flex-direction: column-reverse; flex-wrap: wrap; align-content: center; justify-content: center; } #studentTable{ border-width: 4px; border-style: solid; border-color: lightgray; width: 400px; margin: 0 auto; } tr,td,th{ border-width: 1px; border-style: solid; border-color: lightgray; text-align:center; } /style body div classjsp-example iddDivExample/div div iddDivStudent table idstudentTable thead tr th姓名/th th性别/th /tr /thead tbody idstudentTableBody /tbody /table /div /body script src/springjsp/plugin/jquery/jquery-3.6.0.min.js/script script $(function () { document.getElementById(dDivExample).innerText这是一个springboot3.0jdk17jspwar的测试; showStudent(); }); function showStudent(){ $.ajax({ url: /springjsp/student/list, type: POST, dataType: json, async: true, success: function (rs, status, xhr) { let htmlText; for(let i0,lenrs.length;ilen;i){ htmlTexttrtdrs[i].NAME/tdtdrs[i].sex/td/tr\n } let _bodydocument.getElementById(studentTableBody); _body.innerHTMLhtmlText; }, error: function (rs) { alert(失败!); } }); } /script /html3.4配置wmspackage com.hc.demo.config; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; import com.hc.demo.config.filter.MyFilter; Configuration public class MyWMS extends WebMvcConfigurationSupport { Override protected void addInterceptors(InterceptorRegistry registry) { } Override public void addViewControllers(ViewControllerRegistry registry) { // 为根增加默认的 映射指向index.html registry.addViewController(/).setViewName(index); } Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler(/**).addResourceLocations(classpath:/static/) .addResourceLocations(classpath:/temploates/); registry.addResourceHandler(/plugin/**).addResourceLocations(/plugin/); super.addResourceHandlers(registry); } /** * 注册过滤器 * return */ Bean public FilterRegistrationBeanMyFilter registerAuthFilter() { FilterRegistrationBeanMyFilter registration new FilterRegistrationBean(); MyFilter filternew MyFilter(); registration.setFilter(filter); registration.addUrlPatterns(/*); registration.setName(authFilter); registration.setOrder(1); //值越小Filter越靠前。 return registration; } }上文红色部分是需要关注的地方分别设置根url,静态资源和过滤器。注意这是springboot3.0spring6.0和以往的一个大区别以前的版本过滤器设置需要新建一个web.xml并在web.xml中配置过滤器。但是现在不需要了这个无疑非常方便非常合理。当然这主要是因为 5.0的web moudule可以避免配置web.xml(这个有点烦人。四、打包新建debug Configurations,如下图”jre“部分”VM arguments设置参数-Dmaven.test.skiptrue,避免无谓的测试。其它设置大概如下goals- clean compile package,这是清理、编译最后打包jdk-17字符集-utf-8jrebel 关闭之后点击“debug”则运行如下[INFO] Scanning for projects... [INFO] [INFO] ----------------------- com.hc.demo:springjsp ------------------------ [INFO] Building springjsp 0.0.1-SNAPSHOT [INFO] --------------------------------[ war ]--------------------------------- [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/apache/maven/plugins/maven-clean-plugin/3.2.0/maven-clean-plugin-3.2.0.pom [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/3.2.0/maven-clean-plugin-3.2.0.pom [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/3.2.0/maven-clean-plugin-3.2.0.pom (5.3 kB at 1.5 kB/s) [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/apache/maven/plugins/maven-plugins/35/maven-plugins-35.pom [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/35/maven-plugins-35.pom [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/35/maven-plugins-35.pom (9.9 kB at 1.8 kB/s) [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/apache/maven/maven-parent/35/maven-parent-35.pom [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/35/maven-parent-35.pom [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/35/maven-parent-35.pom (45 kB at 4.2 kB/s) [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/apache/apache/25/apache-25.pom [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/apache/25/apache-25.pom [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/apache/25/apache-25.pom (21 kB at 5.5 kB/s) [INFO] [INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) springjsp --- [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar (169 kB at 7.0 kB/s) [INFO] Deleting E:\codes-java\git\learning\gitee\springjsp\target [INFO] [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) springjsp --- [INFO] Using UTF-8 encoding to copy filtered resources. [INFO] Using UTF-8 encoding to copy filtered properties files. [INFO] Copying 1 resource [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) springjsp --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 7 source files to E:\codes-java\git\learning\gitee\springjsp\target\classes [INFO] [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) springjsp --- [INFO] Using UTF-8 encoding to copy filtered resources. [INFO] Using UTF-8 encoding to copy filtered properties files. [INFO] Copying 1 resource [INFO] Copying 1 resource [INFO] [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) springjsp --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 7 source files to E:\codes-java\git\learning\gitee\springjsp\target\classes [INFO] [INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) springjsp --- [INFO] Not copying test resources [INFO] [INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) springjsp --- [INFO] Not compiling test sources [INFO] [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) springjsp --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-war-plugin:3.3.2:war (default-war) springjsp --- [INFO] Packaging webapp [INFO] Assembling webapp [springjsp] in [E:\codes-java\git\learning\gitee\springjsp\target\springjsp-0.0.1-SNAPSHOT] [INFO] Processing war project [INFO] Copying webapp resources [E:\codes-java\git\learning\gitee\springjsp\src\main\webapp] [INFO]Building war: E:\codes-java\git\learning\gitee\springjsp\target\springjsp.war[INFO] [INFO] --- spring-boot-maven-plugin:3.0.0-SNAPSHOT:repackage (repackage) springjsp --- [INFO] Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-buildpack-platform/3.0.0-SNAPSHOT/maven-metadata.xml [INFO] Downloaded from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-buildpack-platform/3.0.0-SNAPSHOT/maven-metadata.xml (2.4 kB at 1.5 kB/s) [INFO] Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-buildpack-platform/3.0.0-SNAPSHOT/spring-boot-buildpack-platform-3.0.0-20220626.095848-608.pom [INFO] Downloaded from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-buildpack-platform/3.0.0-SNAPSHOT/spring-boot-buildpack-platform-3.0.0-20220626.095848-608.pom (3.4 kB at 2.5 kB/s) [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/net/java/dev/jna/jna-platform/5.7.0/jna-platform-5.7.0.pom [INFO] Downloading from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna-platform/5.7.0/jna-platform-5.7.0.pom [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna-platform/5.7.0/jna-platform-5.7.0.pom (0 B at 0 B/s) [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/net/java/dev/jna/jna/5.7.0/jna-5.7.0.pom [INFO] Downloading from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.7.0/jna-5.7.0.pom [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.7.0/jna-5.7.0.pom (0 B at 0 B/s) [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/tomlj/tomlj/1.0.0/tomlj-1.0.0.pom [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/tomlj/tomlj/1.0.0/tomlj-1.0.0.pom [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/tomlj/tomlj/1.0.0/tomlj-1.0.0.pom (0 B at 0 B/s) [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/antlr/antlr4-runtime/4.7.2/antlr4-runtime-4.7.2.pom [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/antlr/antlr4-runtime/4.7.2/antlr4-runtime-4.7.2.pom [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/antlr/antlr4-runtime/4.7.2/antlr4-runtime-4.7.2.pom (0 B at 0 B/s) [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/antlr/antlr4-master/4.7.2/antlr4-master-4.7.2.pom [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/antlr/antlr4-master/4.7.2/antlr4-master-4.7.2.pom [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/antlr/antlr4-master/4.7.2/antlr4-master-4.7.2.pom (0 B at 0 B/s) [INFO] Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-loader-tools/3.0.0-SNAPSHOT/maven-metadata.xml [INFO] Downloaded from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-loader-tools/3.0.0-SNAPSHOT/maven-metadata.xml (2.4 kB at 1.4 kB/s) [INFO] Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-loader-tools/3.0.0-SNAPSHOT/spring-boot-loader-tools-3.0.0-20220626.095848-608.pom [INFO] Downloaded from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-loader-tools/3.0.0-SNAPSHOT/spring-boot-loader-tools-3.0.0-20220626.095848-608.pom (2.3 kB at 1.4 kB/s) [INFO] Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-buildpack-platform/3.0.0-SNAPSHOT/spring-boot-buildpack-platform-3.0.0-20220626.095848-608.jar [INFO] Downloading from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-loader-tools/3.0.0-SNAPSHOT/spring-boot-loader-tools-3.0.0-20220626.095848-608.jar [INFO] Downloaded from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-loader-tools/3.0.0-SNAPSHOT/spring-boot-loader-tools-3.0.0-20220626.095848-608.jar (247 kB at 39 kB/s) [INFO] Downloaded from spring-snapshots: https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-buildpack-platform/3.0.0-SNAPSHOT/spring-boot-buildpack-platform-3.0.0-20220626.095848-608.jar (240 kB at 35 kB/s) [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/net/java/dev/jna/jna-platform/5.7.0/jna-platform-5.7.0.jar [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/net/java/dev/jna/jna/5.7.0/jna-5.7.0.jar [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/tomlj/tomlj/1.0.0/tomlj-1.0.0.jar [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/antlr/antlr4-runtime/4.7.2/antlr4-runtime-4.7.2.jar [INFO] Downloading from spring-milestones: https://repo.spring.io/milestone/org/codehaus/plexus/plexus-utils/1.5.8/plexus-utils-1.5.8.jar [INFO] Downloading from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna-platform/5.7.0/jna-platform-5.7.0.jar [INFO] Downloading from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.7.0/jna-5.7.0.jar [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/tomlj/tomlj/1.0.0/tomlj-1.0.0.jar [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/antlr/antlr4-runtime/4.7.2/antlr4-runtime-4.7.2.jar [INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.8/plexus-utils-1.5.8.jar [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/tomlj/tomlj/1.0.0/tomlj-1.0.0.jar (0 B at 0 B/s) [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna/5.7.0/jna-5.7.0.jar (0 B at 0 B/s) [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/net/java/dev/jna/jna-platform/5.7.0/jna-platform-5.7.0.jar (0 B at 0 B/s) [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/antlr/antlr4-runtime/4.7.2/antlr4-runtime-4.7.2.jar (0 B at 0 B/s) [INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.8/plexus-utils-1.5.8.jar (268 kB at 38 kB/s) [INFO] Replacing main artifact with repackaged archive [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:31 min [INFO] Finished at: 2022-07-04T22:06:5908:00 [INFO] ------------------------------------------------------------------------五、测试5.1安装和配置tomcat10安装过程略。主要是设置JAVA_HOME和日志编码。5.1.1设置JAVA_HOME打开TOMCAT10的bin\catalina.bat,在”setlocal下插入一句set JAVA_HOMED:\soft\develop-tool\java\jdk-17.0.3.15.1.2设置日志编码打开tomcat10\conf\logging.properties把所有的“UTF-8”修改为“GBK即可。5.2部署war包把前面打包的E:\codes-java\git\learning\gitee\springjsp\target\springjsp.war复制到tomcat10\webapps下。5.3运行war包在cmd下运行tomcat10下的startup.bat,当然之前需要先打开Mysql。控制台输出如下看起来很正常默认8080已经打开。切换到浏览器输入:http://localhost:8080/springjsp/结果如下图运行 正常。六、小结整个过程很顺利麻烦的地方仅仅是配置pom.xml和在wms中配置静态资源。和以前版本比起来的确方便了不少。例如不要配置web.xml实际上web module3.1即可这样可以节省servlet,filter之类的配置。