本文介绍了将独立jar导入本地maven存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令将不能在线获取的第三方jar导入我的本地Maven存储库,用于构建我的项目:

I'm using the following command to import a third-party jar, which is not available online, into my local Maven repository for purposes of building my project:

mvn install:install-file -Dfile=C:\Users\MNXE\plugins\myArtifactTest-generate\myArtifactTest-generate-plugin\lib\autoitx4java.jar -DgroupId=com.autoit.code -DartifactId=autoitx4java -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true

这个jar的pom文件中的依赖关系如下:

The dependency in my pom file for this jar looks like:

    <dependency>
        <groupId>com.autoit.code</groupId>
        <artifactId>autoitx4java</artifactId>
        <version>1.0.0</version>
    </dependency>

以下是尝试安装Maven项目时我的错误的完整堆栈跟踪。无论我尝试安装jar,还是在Eclipse的构建路径中包含jar,似乎没有什么工作。我继续收到编译错误:

The following is the full stack trace of my error while attempting to install the Maven project. Regardless of my attempt to install the jar, or include the jar in my build path in Eclipse, nothing seems to work. I continue to get a compilation error:

C:\Users\MNXE\plugins\myArtifactTest-generate>mvn install -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] OO sample content project
[INFO] myArtifactTest-generate-plugin
[INFO] myArtifactTest-generate-cp
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building OO sample content project 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ myArtifactTest
-generate ---
[INFO] Installing C:\Users\MNXE\plugins\myArtifactTest-generate\pom.xml to C:\Us
ers\MNXE\.m2\repository\myGroupTest-generate\myArtifactTest-generate\1.0.0\myArt
ifactTest-generate-1.0.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myArtifactTest-generate-plugin 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- oo-action-plugin-maven-plugin:10.20.8:generate-action-plugin (generat
e-contentpack-plugin) @ myArtifactTest-generate-plugin ---
[INFO]
[INFO] --- maven-plugin-plugin:2.9:descriptor (default-descriptor) @ myArtifactT
est-generate-plugin ---
[WARNING] Using platform encoding (Cp1250 actually) to read mojo metadata, i.e.
build is platform dependent!
[INFO] Applying mojo extractor for language: java
[INFO] Mojo extractor for language: java found 4 mojo descriptors.
[INFO] Applying mojo extractor for language: bsh
[INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ myArtifact
Test-generate-plugin ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\MNXE\plugins\myArtifactTest-
generate\myArtifactTest-generate-plugin\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myArtifactTest-
generate-plugin ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1250, i.e. b
uild is platform dependent!
[INFO] Compiling 5 source files to C:\Users\MNXE\plugins\myArtifactTest-generate
\myArtifactTest-generate-plugin\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[9,20] package autoitx4java does not exis
t
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[123,38] cannot find symbol
  symbol:   class AutoItX
  location: class SampleActions
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[128,41] cannot find symbol
  symbol:   class AutoItX
  location: class SampleActions
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[133,39] cannot find symbol
  symbol:   class AutoItX
  location: class SampleActions
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] OO sample content project ......................... SUCCESS [0.817s]
[INFO] myArtifactTest-generate-plugin .................... FAILURE [6.999s]
[INFO] myArtifactTest-generate-cp ........................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.994s
[INFO] Finished at: Thu May 12 11:33:43 CEST 2016
[INFO] Final Memory: 17M/213M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:compile (default-compile) on project myArtifactTest-generate-plugin: Compilati
on failure: Compilation failure:
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[9,20] package autoitx4java does not exis
t
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[123,38] cannot find symbol
[ERROR] symbol:   class AutoItX
[ERROR] location: class SampleActions
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[128,41] cannot find symbol
[ERROR] symbol:   class AutoItX
[ERROR] location: class SampleActions
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[133,39] cannot find symbol
[ERROR] symbol:   class AutoItX
[ERROR] location: class SampleActions
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on p
roject myArtifactTest-generate-plugin: Compilation failure
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compila
tion failure
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(Abstrac
tCompilerMojo.java:858)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.ja
va:129)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
        ... 19 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <goals> -rf :myArtifactTest-generate-plugin
C:\Users\MNXE\plugins\myArtifactTest-generate>


推荐答案

我认为你的jar文件中缺少版本号名称。您的jar文件名应为autoitx4java- 1.0.0 .jar

I think you are missing version number in your jar file name. Your jar file name should be autoitx4java-1.0.0.jar

这篇关于将独立jar导入本地maven存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 10:07
查看更多