【问题标题】:Failed to execute goal org.apache.maven.plugins - package does not exist未能执行目标 org.apache.maven.plugins - 包不存在
【发布时间】:2018-01-11 18:50:45
【问题描述】:

我正在尝试使用mvn install,但我不断收到此错误

    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project example-module-core: Compilation failure: Compilation failure:
[ERROR] /C:/terasoluna-plus/example-module-core/src/main/java/com/mycompany/project/module/util/InitServlet.java:[10,47] package org.springframework.web.context.support does not exist
[ERROR] /C:/terasoluna-plus/example-module-core/src/main/java/com/mycompany/project/module/service/impl/DatabaseServiceImpl.java:[9,50] package org.springframework.transaction.annotation does not exist
[ERROR] /C:/terasoluna-plus/example-module-core/src/main/java/com/mycompany/project/module/service/impl/DatabaseServiceImpl.java:[22,2] cannot find symbol
[ERROR] symbol: class Transactional
[ERROR] /C:/terasoluna-plus/example-module-core/src/main/java/com/mycompany/project/module/service/impl/InitializerServiceImpl.java:[11,50] package org.springframework.transaction.annotation does not exist
[ERROR] /C:/terasoluna-plus/example-module-core/src/main/java/com/mycompany/project/module/service/impl/InitializerServiceImpl.java:[28,2] cannot find symbol
[ERROR] symbol: class Transactional
[ERROR] /C:/terasoluna-plus/example-module-core/src/main/java/com/mycompany/project/example-module-core/src/main/java/com/mycompany/project/module/util/InitServlet.java:[25,11] cannot find symbol
[ERROR] symbol:   variable SpringBeanAutowiringSupport
[ERROR] location: class com.mycompany.SIAR.module.util.InitServlet
[ERROR] -> [Help 1]

在我的 InitServlet.java 中,我有所有的导入,并且没有错误。在 pom.xml 中我有所有需要的依赖项,但这个问题总是存在。

所有其他解决方案都告诉我添加依赖项并使用 Maven 更新,但它绝对不会缺少代码/依赖项,因为这个项目正在与其他 2 个用户共享,并且它在其他机器上运行良好。这是完全相同的项目。

我让这个工作了几个小时,在无数次尝试mvn clean install 之后,其中一个获得了 BUILD SUCCESS 并且我没有改变任何东西,它工作正常。但是后来改了一些java文件后,我用mvn clean install,又报同样的错误。

你有什么想法吗?

提前致谢。

【问题讨论】:

    标签: spring maven web-applications maven-2 maven-plugin


    【解决方案1】:

    您需要将maven-compiler-plugin 添加到pom.xml。您可以在下面找到插件代码并将源版本替换为您的 jdk 版本:

       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>1.8</source>   // jdk version
                <target>1.8</target>   // jdk version
            </configuration>
        </plugin>
    

    【讨论】:

      【解决方案2】:

      当它在具有精确 pom 的其他系统上工作时,而不是在我的系统上工作时,我会研究差异......

      1. 在我的本地存储库中 - 删除有问题的依赖项并运行 mvn clean install。需要的任何依赖项都将由 maven 再次下载。

      2. 在我的 maven settings.xml 中 - 在 ${MAVEN_HOME}/conf 位置。有什么区别,我是否覆盖了任何设置?

      3. JDK 版本和 Maven 版本的区别。

      我希望这会有所帮助。

      【讨论】:

      • 感谢您的回复。我尝试了您的解决方案,但同样的错误仍然存​​在。 JDK版本和Maven完全一样,因为都是新机,安装的文件都是一样的。
      【解决方案3】:

      我修好了。显然,它确实需要在另一个文件夹上的 pom.xml 上再增加 2 个依赖项。我需要将这两个依赖项添加到核心文件夹中的 pom.xml 中。

      <dependency>
        <groupId>org.terasoluna.plus.framework</groupId>
        <artifactId>terasoluna-plus-web-conf</artifactId>
      </dependency>
      <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-tx</artifactId>
      </dependency>
      

      添加后运行mvn clean install,安装成功。无论如何,谢谢你的帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-03-15
        • 1970-01-01
        • 2020-09-06
        • 1970-01-01
        • 2019-08-30
        • 2016-08-11
        • 2015-02-01
        • 2013-10-11
        相关资源
        最近更新 更多