renrenfast2.0(springboot)打jar包运行出错,报jar包冲突,原因是加入了阿里云短信SDK,没配置好

    xiaoxiao2022-07-14  181

    正在开发一个系统,用的renrenfast2.0(springboot)开源框架,结果编译没问题,打jar包没问题,运行时候出错,报jar包冲突,原因是项目里加入了阿里云短信SDK,没配置好

    报错情况:

    org.springframework.context.ApplicationContextException: Unable to start web server; Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerExcept Unable to Start embedded TomCat Java.lang.NoClassDefFoundError:com/aliyuncs/exceptions/ClientException

    问题根源:阿里云Jar包配置后,打包插件没配置好,导致打的jar包可能出现重复,故报jar包冲突错误。

    正确的做法:除了正常的引入jar包外,还需要在打包插件中配置。

    1.正常引入jar包

    <!--配置外部jar包依赖--> <dependency> <groupId>com.yzm</groupId> <artifactId>alicom-mns-receive-sdk-1.0.1</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/alicom-mns-receive-sdk-1.0.1.jar</systemPath> </dependency> <dependency> <groupId>com.yzm</groupId> <artifactId>alicom-mns-receive-sdk-1.0.1-sources</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/alicom-mns-receive-sdk-1.0.1-sources.jar</systemPath> </dependency> <dependency> <groupId>com.yzm</groupId> <artifactId>aliyun-java-sdk-core-3.3.1</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/aliyun-java-sdk-core-3.3.1.jar</systemPath> </dependency> <dependency> <groupId>com.yzm</groupId> <artifactId>aliyun-java-sdk-dysmsapi-1.0.0</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/aliyun-java-sdk-dysmsapi-1.0.0.jar</systemPath> </dependency> <dependency> <groupId>com.yzm</groupId> <artifactId>aliyun-sdk-mns-1.1.8</artifactId> <version>1.0.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/aliyun-sdk-mns-1.1.8.jar</systemPath> </dependency> </dependencies> <build> <!--配置外部jar包--> <resources> <resource> <directory>lib</directory> <targetPath>admin-backend/lib/</targetPath> <includes> <include>**/*.jar</include> </includes> </resource> </resources> </build>

    2.打包插件中配置

    直接在maven的pom里给springboot的打包插件引入一下参数就行 <includeSystemScope>true</includeSystemScope>

    实际地点:

    <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> </plugins> </build>

    原文出自:艾特老司机

    https://blog.csdn.net/csdn2193714269/article/details/78391274 

    最新回复(0)