maven 打包文件显示程序包不存在问题 -- (插件配置问题)

问题

1.SpringBoot项目中有两个模块A和B,在A模块中引入B模块jar包,当使用maven打包A模块的jar包时,显示错误 :程序包com.xxx不存在。(程序包com.xxx为B模块中的某个类)

2.但是本地能运行A模块。

3.先使用maven命令install B模块,成功,再install A模块,依然报同样的错误;

解决

在B模块的pom文件中, 发现这个springboot maven的打包插件:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <mainClass>com.eshore.paas.ops.serv.copmgr.CopMgrApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

原因:
一般对使用spring-boot-maven-plugin插件打出的可执行jar不建议作为jar给其他服务引用,因为可能出现访问可执行jar中的一些配置文件找不到的问题

最后将B中的spring-boot-maven-plugin打包插件注释掉,再重新对A模块进行打包,成功

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值