maven打包时怎么lib下的jar包引入进去

spring boot项目打包完,放到Linux环境,报错
报错信息如下;
Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/openapi/sdk/service
原因就是引入的外部的jar包没有生效
项目引用外部jar的位置如下;

在这里插入图片描述

在pom文件中引入外部jar的代码
<dependency>
			<groupId>com.chehuida</groupId>
			<artifactId>um-core</artifactId>
			<version>1.0.1</version>
		</dependency>
		<dependency>
        <groupId>com.test</groupId>
        <artifactId>test</artifactId>
        <scope>system</scope>
        <version>1.0</version>
        <systemPath>${
    
    project.basedir}/src/main/resources/lib/openapi-sdk.jar</systemPath>
    </dependency> 
打包时,加上这几行代码就OK了,完美解决
<configuration>
        <includeSystemScope>true</includeSystemScope>
                </configuration>

		
		<plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
        <includeSystemScope>true</includeSystemScope>
                </configuration>
            
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin> 

猜你喜欢

转载自blog.csdn.net/qq_38220334/article/details/107858414
今日推荐