以下是pom.xml需要增加的配置?
<build>
<!--打包成war包的文件名,也是请求的上下文路径-->
<finalName>bank</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF</directory>
<targetPath>/WEB-INF</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
点击install (mvn clean install)?,进行war打包


现在docker tomcat的latest版本为10,但无法将该Spring项目成功部署,需要将镜像换至tomcat9才能成功
可提前在/var/lib/docker/volumes下新建好具名挂载目录以及_data,将war包上传至_data目录下,然后创建tomcat9容器
docker run -d -p 3001:8080 --name bank_tomcat -v bank_server:/usr/local/tomcat/webapps tomcat:9

|