我是 Maven 环境的新手。在我的项目中,我需要使用我在本地安装的外部 jar,但是在构建编译时,maven 仍然搜索 Intranet repo 并且构建编译失败。在日志中,我可以看到它在进行 make 时安装了外部 jar,但是在编译时(或者可能是在项目 pom 并找到依赖项时)它尝试再次从 Intranet repo 下载相同的 jar 并失败。
这是我在makefile中用来在本地安装jar的命令,
$(MVNBLD) install:install-file -Dfile=jarName.jar -DgroupId=com.example.project -DartifactId=jarName -Dversion=1.0 -Dpackaging=jar -Dgenerate`enter code here`Pom=true -gs settings.xml
有什么办法可以强制 maven 去查看本地 repo 而不是上网。
=============
我尝试了Maven 中给出的解决方案:通过相对路径向 jar 添加依赖项...。至少我没有遇到 jar 下载问题。但它仍然无法使用以下错误编译构建,
Exception in thread "main" java.lang.NoClassDefFoundError: '-Xmx1024m
Caused by: java.lang.ClassNotFoundException: '-Xmx1024m
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: '-Xmx1024m. Program will`enter code here` exit.
make: *** [prod_jar] Error 1
Command finished (error code: 2)
它仍然没有找到依赖jar吗?