构建Spring启动项目时出错

时间:2017-09-12 11:52:14

标签: java spring eclipse maven spring-boot

我无法构建springboot项目, 我正在使用来自另一个springboot jar的类,我把它放在构建路径上,它通过eclipse在本地运行,但是没有构建,这里是错误

tbody

无论我在外部jar中使用类/函数,它都显示错误,有人可以帮忙吗? 我的POM -

这是我的POM

"[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ContentManagementService 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ contentmanagementapi ---
[INFO] Deleting /home/bhargavgundu/git/contentmanagementservice/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ contentmanagementapi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ contentmanagementapi ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 42 source files to /home/bhargavgundu/git/contentmanagementservice/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[32,31] package com.conduiraonline.apis does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[42,31] package com.conduiraonline.daos does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[52,35] cannot find symbol
  symbol:   class SlackService
  location: package com.conduiraonline.services
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[85,17] cannot find symbol
  symbol:   class UserDAO
  location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[87,17] cannot find symbol
  symbol:   class SlackService
  location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[95,17] cannot find symbol
  symbol:   class LicenseV5
  location: class com.conduiraonline.controller.ContentManagementControllerV1
[INFO] 6 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.917s
[INFO] Finished at: Tue Sep 12 17:16:44 IST 2017
[INFO] Final Memory: 24M/396M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project contentmanagementapi: Compilation failure: Compilation failure:
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[32,31] package com.conduiraonline.apis does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[42,31] package com.conduiraonline.daos does not exist
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[52,35] cannot find symbol
[ERROR] symbol:   class SlackService
[ERROR] location: package com.conduiraonline.services
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[85,17] cannot find symbol
[ERROR] symbol:   class UserDAO
[ERROR] location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[87,17] cannot find symbol
[ERROR] symbol:   class SlackService
[ERROR] location: class com.conduiraonline.controller.ContentManagementControllerV1
[ERROR] /home/bhargavgundu/git/contentmanagementservice/src/main/java/com/conduiraonline/controller/ContentManagementControllerV1.java:[95,17] cannot find symbol
[ERROR] symbol:   class LicenseV5
[ERROR] location: class com.conduiraonline.controller.ContentManagementControllerV1
[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
"

2 个答案:

答案 0 :(得分:1)

TL; DR

<classifier>exec</classifier>

的依赖项中删除com.conduiraonline:licenseapi

更多详情......

使用<dependency>来表达com.conduiraonline:contentmanagementapicom.conduiraonline:licenseapi之间的关系是正确的。或者用另一种方式;这是正确的方式告诉Maven模块com.conduiraonline:contentmanagementapi取决于模块com.conduiraonline:licenseapi

但是,您已将com.conduiraonline:licenseapi的依赖关系定义为:

    <dependency>
        <groupId>com.conduiraonline</groupId>
        <artifactId>licenseapi</artifactId>
        <version>0.0.1</version>
        <classifier>exec</classifier>
    </dependency>

classifier告诉Maven在本地Maven仓库中的licenseapi.exec文件夹中查找名为com/conduiraonline的文件(如果失败了,请尝试从任何远程存储库中解析该依赖关系已在Maven settings.xml或此pom.xml中配置。)

我认为本地Maven仓库中的文件夹licenseapi.exec中没有名为com/conduiraonline的文件,因为exec是Maven工件的一个非常不寻常的分类器。

只要在您的本地Maven仓库中安装了版本为com.conduiraonline:licenseapi的{​​{1}}的JAR,此依赖关系就会起作用:

0.0.1

通过为 <dependency> <groupId>com.conduiraonline</groupId> <artifactId>licenseapi</artifactId> <version>0.0.1</version> </dependency> 模块运行com.conduiraonline:licenseapi,在本地Maven仓库中为版本为0.0.1的{​​{1}}安装JAR(假设{的pom.xml为{ {1}}个模块有mvn clean install)。

答案 1 :(得分:0)

您必须在gradle或maven构建文件中添加包含jar的jar /文件夹的路径。

例如在gradle中添加

    compile fileTree(dir: 'path_to_ext_libs', include: '*.jar')

到build.gradle中的依赖项,然后将包含libs文件夹中的所有jar文件。

或在maven中

<repositories>
   <repository>
     <id>local-files</id>
     <name>local-files</name>
     <url>file://c:\test\filerepo</url>
  </repository>