springboot项目打包并部署到Tomcat上及报错处理方案
作者:xxx_kkkkk
一、打包springboot项目
双击clean再双击package
报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project springboot_vue: The plugin org.apache.maven.plugins:maven-compiler-plugin:3.13.0 requires Maven version 3.6.3 -> [Help 1]
方法1:查看file->setting,Build,Executive,Deployment中的Build Tools下的Maven下的Importing 、Runner、Complier -> Java Compiler有关Java版本是否不为空或者正确
方法2:查看file->projectStructure,Project、Modules、SDKs是否为空或正确
以上两个方法没有解决我的问题
我的解决方法:重新装一遍Maven version 3.6.3,因为我的Maven版本之前是3.6.1(这个方法成功打包)
setting中重新配置Maven
二、部署到Tomcat
将jar包复制到tomcat安装目录下的webapps文件夹下面
在当前目录有点打开cmd
输入命令:java -jar xxxxx.jar
如果在启动时报错: xxxxx.jar中没有主清单属性
pom.xml文件中加上:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
启动失败:14404,端口占用
可能是你的tomcat服务器开着(startup.bat),需要关掉
完整的pom.xml文件
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.3.0</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.itvue</groupId> <artifactId>springboot_vue</artifactId> <version>0.0.1-SNAPSHOT</version> <name>springboot_vue</name> <description>springboot_vue</description> <properties> <java.version>17</java.version> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>3.0.3</version> </dependency> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter-test</artifactId> <version>3.0.3</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
到此这篇关于springboot项目打包并部署到Tomcat上及报错处理的文章就介绍到这了,更多相关springboot项目打包部署Tomcat内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!