springboot项目手动引入第三方jar包打包后启动失败

ppylox
·2/5/2023·0 阅读
AI 摘要模型根据正文自动生成,仅供参考

Spring Boot项目通过system scope引入第三方jar包后,本地运行正常但打包启动报错“Lookup method resolution failed”。原因是spring-boot-maven-plugin默认不打包system scope依赖。解决办法是在该插件configuration中添加`<includeSystemScope>true</includeSystemScope>`,使第三方jar被打入最终包,从而正常启动。

大家好我是图恩,最近在优化后端服务代码的时候引入了第三方jar包,本地开发调试的时候一切正常,通过package命令打包后再通过-jar命令启动的时候启动报错,提示一下错误信息:

Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class
[com.dsiab.manageService.controller.PromoteController] from ClassLoader ...

pom.xml文件代码如下,jar包文件放在resource目录下。

\n<dependency>\n     <groupId>com.dsiab</groupId>\n     <artifactId>dsiab</artifactId>\n     <scope>system</scope>\n     <version>1.0</version>\n     <systemPath>${basedir}/src/main/resources/lib/xxx.jar</systemPath>\n</dependency>

最终解决办法就是在pom文件中的build配置中加入includeSystemScope命令

<build>\n        <plugins>\n            <plugin>\n                <groupId>org.springframework.boot</groupId>\n                <artifactId>spring-boot-maven-plugin</artifactId>\n                <version>2.6.5</version>\n                <!-- 打包时可以通过jar命令单独运行 -->\n                <executions>\n                    <execution>\n                        <goals>\n                            <goal>\n                                repackage\n                            </goal>\n                        </goals>\n                    </execution>\n                </executions>\n                <!--加入这个includeSystemScope,解决引入第三方包后本地运行正常,打包后报错问题-->\n                <configuration>\n                    <includeSystemScope>true</includeSystemScope>\n                </configuration>\n            </plugin>\n        </plugins>\n    </build>\n


相关文章

评论 (0)

暂无评论,来写第一条吧