【Tools】IDEA中Maven项目直接引入第三方Jar包运行打包发布导致的问题解决方法

一、说明

最近在做一个地图生成等值面的后端接口时,需要引一个wContour.jar包,maven打包后发布线上发现引入的Jar包找不到(class not found),纠结了一会,发现其实pom文件中plugin配置一下即可。

二、操作

1. 拷贝文件到项目中:可在对应Moudle模块下创建lib文件夹,将jar文件复制到里面。
在这里插入图片描述

2. 在File/Project Structure/Libraries中,点击添加,选择java。
在这里插入图片描述
3. 选择对应文件
在这里插入图片描述
4. 选择指定模块,将对应library添加进去
在这里插入图片描述
5. pom文件配置

		<!--groupId、artifactId、version自定义-->
        <dependency>
            <groupId>wContour</groupId>
            <artifactId>wContour</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${
    
    pom.basedir}/lib/wContour.jar</systemPath>
        </dependency>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                 	<!--解决本地jar包打不进jar的问题-->
                    <includeSystemScope>true</includeSystemScope>  
                </configuration>
            </plugin>
        </plugins>
    </build>

猜你喜欢

转载自blog.csdn.net/weixin_42029283/article/details/130648087