我需要将第三方 jar 添加到我的项目中,该项目使用 Maven 进行依赖管理。
由于第三方 jar 在 maven-central 中不可用,我已使用以下命令将其安装到本地 .m2 存储库中
mvn install:install-file -Dfile=ThirdPartyApp.jar -DgroupId=com.thirdpartydomain -DartifactId=ThirdPartyApp -Dversion=1.0 -Dpackaging=jar
并使用以下依赖项片段将其添加到我的项目中
<dependency>
<groupId>com.thirdpartydomain</groupId>
<artifactId>ThirdPartyApp</artifactId>
<version>1.0</version>
</dependency>
我的项目构建成功(通过使用 mvn clean 包)
但是当我尝试导入它时,它失败了
import com.thirdpartydomain.*;
导入com.thirdpartydomain无法解析
最佳答案
包名称不一定与组 ID 相同。另外,如果您使用某些 IDE(例如 Eclipse 或 IDEA),请重新生成项目设置和类路径。
关于java - 无法导入通过maven添加的包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56674150/