springBoot引用第三方jar包,项目打包时jar包打不进

2020-09-18  本文已影响0人  原始人y

问题描述:
最近在写一个demo的时候,需要用到一个外部jar包,此jar包不是存在于maven,所以得引入这个jar包,idea是可以直接跑调用是没问题的。但是打成war包部署的时候,就爆java.lang.NoClassDefFoundError错误。后经过度娘帮忙,解决此问题。
解决方法:
1.引入本地jar包,在目录下新建一个lib文件夹,将jar包放到lib下面:


image.png

2.在pom文件中添加依赖:


image.png
<dependency>
            <groupId>pdd2</groupId>
            <artifactId>pop-sdk</artifactId>
            <version>1.9.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/pop-sdk-1.9.1.jar</systemPath>
        </dependency>

注意:systemPath是你jar包的路径,不能乱填。其他的随便填都可以
3.直接在maven的pom里给springboot的打包插件引入一下参数:

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

            </plugin>
        </plugins>
    </build>

完成

上一篇 下一篇

猜你喜欢

热点阅读