[Tools] The Maven project in IDEA directly introduces the third-party Jar package to run, package and release the problem solution

Table of contents

1. Description

Recently, when I was doing a back-end interface for map generation isosurfaces, I needed to import a wContour.jar package. After maven packaged it and released it online, I found that the imported Jar package could not be found (class not found). After struggling for a while, I found that it was actually Just configure the plugin in the pom file.

Two, operation

1. Copy the file to the project: You can create a lib folder under the corresponding Moudle module, and copy the jar file into it.
insert image description here

2. In File/Project Structure/Libraries, click Add and select java.
insert image description here
3. Select the corresponding file
insert image description here
4. Select the specified module and add the corresponding library
insert image description here
5. Pom file configuration

		<!--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>

Guess you like

Origin blog.csdn.net/weixin_42029283/article/details/130648087