• Springboot项目 导出生成jar包


    方法1

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

    等待运行 BUILD SUCCESS

    在这里插入图片描述

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

    java -jar xxxx.jar
    
    • 1

    在这里插入图片描述

    方法2

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

    		mvn package -Dmaven.test.skip=true
    
    • 1

    可能存在的问题

    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>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    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>-->
    
    • 1
    • 2
    • 3
    • 4

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

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

    4、如果通过如下 dependency配置不成功,左侧出现红色叉号

    		<dependency>
    		    <groupId>org.codehaus</groupId>
    		    <artifactId>xfire</artifactId>
    		    <version>1.2.6-all-patch-671</version>
    		</dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5

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

  • 相关阅读:
    源码分析:Websocket 和前端交互
    【AIGC】Stable Diffusion Prompt 每日一练0916
    预约陪诊系统开发,跨省就医也能省时省力
    Linux(基于Centos7)(四)
    设计模式【1】-- 单例模式
    C/C++:VSCode配置C++开发环境【Windows系统】
    nginx的配置文件概述及简单demo(二)
    STM32按键状态机2——状态简化与增加长按功能
    2019 LCLR | How Powerful are Graph Neural Networks
    c++的数据类型的引用(三种方式有一些区别)
  • 原文地址:https://blog.csdn.net/qq_41749451/article/details/126520976