Springboot项目 导出生成jar包

方法1

1、先clean下项目
在这里插入图片描述
2、项目右键-run as -maven install
在这里插入图片描述

等待运行 BUILD SUCCESS

在这里插入图片描述

3、打开项目所在文件夹,找到 target 文件夹,有打包生成的jar包
在这里插入图片描述
4、测试jar包,当前目录下进cmd,输入

java -jar xxxx.jar

在这里插入图片描述

方法2

1、打开项目所在文件夹,当前目录下进cmd,输入

		mvn package -Dmaven.test.skip=true

可能存在的问题

1、Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project handset: Unable to generate classpath: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing

解决办法:在pom.xml中添加如下语句,可跳过测试

		<!-- -EclipseMaven 打包项目时如何跳过 test 用例 -->
			<plugin>
		        <groupId>org.apache.maven.plugins</groupId>
		        <artifactId>maven-surefire-plugin</artifactId>
		        <configuration>
		          <skip>true</skip>
		        </configuration>
		      </plugin>
2、Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.1.RELEASE:repackage (repackage) on project start: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.3.1.RELEASE:repackage failed: Unable to find a single main class from the following candidates [com.boc.DemoApplication, com.example.demo.DemoApplication] -> [Help 1]

解决办法:在pom.xml中注释掉如下语句:

			<!--<plugin>-->
				<!--<groupId>org.springframework.boot</groupId>-->
				<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
			<!--</plugin>-->
3、org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘Total’: Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.apache.commons.dbcp.BasicDataSource] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Total': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.apache.commons.dbcp.BasicDataSource] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]

Caused by: java.lang.NoClassDefFoundError: org/codehaus/xfire
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.getDeclaredMethods(Class.java:1975)
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:662)
	... 55 more

解决办法:maven仓库配置 org/codehaus/xfire 即可

4、如果通过如下 dependency配置不成功,左侧出现红色叉号
		<dependency>
		    <groupId>org.codehaus</groupId>
		    <artifactId>xfire</artifactId>
		    <version>1.2.6-all-patch-671</version>
		</dependency>

在这里插入图片描述
则可以采用命令行安装 jar包。见链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值