maven package: can not find symbol symbol: method getXxx ()

Foreword

First explain to my side of the case, should not match with the results you want, do not spray.

+ Project polymerization used mvn install instruction

Detailed Description

Polymerization project, the main module A need to play war packet, other modules BCD need to play for the jar packet as it depends.

Look at the screenshot of error:

Prior to this problem lies in playing war when the package, use the mvn install command, it depends on BCD are scored local Maven repository, and BCD after the change, because there is no plus clean execution, execution again and did not re-compiled package , resulting in new property fields and methods not found .

So to figure out mvn install with mvn clean install or mvn package differences.

package命令:完成了项目编译、单元测试、打包功能,但没有把打好的可执行jar包(war包或其它形式的包)布署到本地 maven 仓库和远程 maven 私服仓库

install命令:完成了项目编译、单元测试、打包功能,同时把打好的可执行jar包(war包或其它形式的包)布署到本地 maven 仓库,但没有布署到远程 maven 私服仓库

deploy命令:完成了项目编译、单元测试、打包功能,同时把打好的可执行jar包(war包或其它形式的包)布署到本地 maven 仓库和远程 maven 私服仓库.

命令说明参考链接:https://blog.csdn.net/baidu_41632451/article/details/94742874

clean 的作用则是帮助你清除本地 jar、所以配合 install 就得到最新版本 jar 的效果了 > mvn clean install,同样的也可以使用 mvn clean package

但是需要注意的是,clean 是一件相对比较耗时的操作,如果没有修改其他模块,可放弃使用。

当然,如果你不想用 mvn clean 但是又想保持 jar 是最新版本,则可以使用 -Djar.forceCreation 参数,这个参数会强制更新 jar 包。

个人建议:为保险起见,建议使用 clean 指令。

解决方法

1、使用 mvn clean install 或者是 mvn clean package 重新进行打包操作。

2、使用 mvn install -Djar.forceCreation 或者 mvn pakcage -Djar.forceCreation

3、如果上边两种方法都试了,还是不行,直接找到自己的 maven 仓库地址,把 BCD 给删了,重新执行打包命令。

分享副业

分享一下最近在做的副业,赚点外快~

Guess you like

Origin www.cnblogs.com/niceyoo/p/12203846.html