问题描述
Idea中Maven引入包死活引入不进来。代码提示要引入某个包,但是引入之后,也不能import,这时候一般都是pom文件里面不对。
解决
在Terminal中执行如下命令:
mvn dependency:tree -Dverbose=true -Dincludes=groupId:artifactId
执行之后,查看是否有包冲突的情况或者缺少版本等信息,如下:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.hnchasing:trust-modules-proxy:jar:3.6.2
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: junit:junit:jar -> duplicate declaration of version (?) @ line 136, column 21
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.oracle.database.jdbc:ojdbc6:jar -> duplicate declaration of version 11.2.0.4 @ line 142, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ com.hnchasing:trust:3.6.2, D:\cc\trust\code_new\trust-business-management\pom.xml, line 276, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------------< com.hnchasing:trust-modules-proxy >------------------
[INFO] Building trust-modules-proxy 3.6.2
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ trust-modules-proxy ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.302 s
[INFO] Finished at: 2023-08-17T09:53:57+08:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "nexus" could not be activated because it does not exist.
总结
mvn dependency:tree 是 Maven 中的一个命令,它用于生成项目的依赖树。该命令会列出项目所依赖的所有库,以及这些库的依赖。这样,你可以清楚地看到你的项目间接依赖的所有库。
-Dverbose=true 是一个系统属性,该属性会使 Maven 在执行过程中输出更详细的日志信息。
-Dincludes=groupId:artifactId 是一个用来指定你想要包含在依赖树中的特定依赖的参数。在这个参数中,你需要提供 groupId 和 artifactId,它们是 Maven 项目的唯一标识符。这个参数可以接受多个值,只需要用逗号隔开即可,如 -Dincludes=groupId1:artifactId1,groupId2:artifactId2。
总的来说,这个命令的作用是生成一个包含你指定的特定依赖的详细的依赖树。
版权归原作者 动哒 所有, 如有侵权,请联系我们删除。