我手动在位于.m2 / repository的Maven存储库下添加了一个jar文件。
然后我还编辑了项目的pom.xml文件
jar文件也出现在Maven Dependencies
下但是,当我在源文件的根目录下执行此命令mvn assembly:assembly -DdescriptorId=jar-with-dependencies package
时,我会收到此错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project alexa-skills-kit-samples: Compilation failure: Compilation failure:
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/response/WowLampSmartControlResponse.java:[5,16] package org.json does not exist
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/http_request/WowLampSmartControlRequest.java:[7,16] package org.json does not exist
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/http_request/WowLampSmartControlRequest.java:[8,16] package org.json does not exist
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/http_request/WowLampSmartControlRequest.java:[16,19] cannot find symbol
[ERROR] symbol: class JSONObject
[ERROR] location: class http_request.WowLampSmartControlRequest
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/http_request/WowLampSmartControlRequest.java:[30,62] cannot find symbol
[ERROR] symbol: class JSONException
[ERROR] location: class http_request.WowLampSmartControlRequest
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/http_request/WowLampSmartControlRequest.java:[67,51] cannot find symbol
[ERROR] symbol: class JSONException
[ERROR] location: class http_request.WowLampSmartControlRequest
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/response/WowLampSmartControlResponse.java:[127,24] cannot find symbol
[ERROR] symbol: class JSONException
[ERROR] location: class response.WowLampSmartControlResponse
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/http_request/WowLampSmartControlRequest.java:[32,37] cannot find symbol
[ERROR] symbol: class JSONObject
[ERROR] location: class http_request.WowLampSmartControlRequest
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/http_request/WowLampSmartControlRequest.java:[74,17] cannot find symbol
[ERROR] symbol: class JSONObject
[ERROR] location: class http_request.WowLampSmartControlRequest
[ERROR] /Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/src/main/java/wowlampsmartcontrol/http_request/WowLampSmartControlRequest.java:[74,45] cannot find symbol
[ERROR] symbol: class JSONObject
[ERROR] location: class http_request.WowLampSmartControlRequest
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
我不明白为什么会这样。
-----更新-----
我也尝试通过命令添加jar:
mvn install:install-file -Dfile=/Users/jun/Desktop/Projects/WowLamp/alexa-skills-kit-java-master/samples/lib/java-json.jar -DgroupId=json.java -DartifactId=java-json -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
这是安装后jar文件的层次结构:
但仍然会发生同样的错误。
答案 0 :(得分:1)
您需要使用以下命令安装jar,而不是手动将其复制到存储库中。
mvn install:install-file -Dfile=java-json-1.0.jar -DgroupId=json.java \
-DartifactId=java-json -Dversion=1.0 -Dpackaging=jar
您可以咨询专家doc了解更多详情。