创建Maven项目时出错

时间:2015-11-09 17:08:59

标签: maven mule anypoint-studio

我正在尝试按照本教程https://docs.mulesoft.com/mule-user-guide/v/3.7/building-a-mule-application-with-maven-in-studio创建maven项目,那时Studio自动构建Maven项目,我收到此错误:updating maven project has encountered a problem There was an error running the studio:studio goal on project test并在控制台中:

[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.mycompany:test:1.0.0-SNAPSHOT (C:\Users\Rajeun\AnypointStudio\workspace\test\pom.xml) has 2 errors
[ERROR]     Unresolveable build extension: Plugin org.mule.tools.maven:mule-app-maven-plugin:1.1 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:1.5.0 at specified path C:\Program Files (x86)\Java\jre1.8.0_40/../lib/tools.jar -> [Help 2]
[ERROR]     Unknown packaging: mule @ line 8, column 16
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException

9 个答案:

答案 0 :(得分:13)

在你的anypoint工作室转到windows>>首选项>>在左侧菜单中选择 java >>安装jre将其更改为jdk路径enter image description here

答案 1 :(得分:5)

我解决了这个问题,我不确切知道什么有效但我更改了java版本,并且每个项目都执行以下命令:

mvn clean install
mvn eclipse:eclipse

然后我刷新我的项目 这有助于:http://www.avajava.com/tutorials/lessons/how-do-i-update-my-maven-project-to-work-in-eclipse.html

答案 2 :(得分:3)

我遇到了同样的问题,并通过在首选项中将JRE更改为JDK并重新启动任何点工作室得到解决。 这解决了我的问题。

答案 3 :(得分:2)

我遇到了同样的错误,我解决了这个问题,不仅仅是在已安装的JRE中添加JDK,而是将JAVASE-1.8的执行环境设置为jdk1.8并且工作正常。 enter image description here

答案 4 :(得分:1)

检查 MuleStudio.ini 是否包含JDK正确路径的配置:

-vm
C:\Path\To\Your\JDK\bin\javaw

答案 5 :(得分:1)

您需要为插件添加Maven依赖项

步骤1:编辑settings.xml以使用以下存储库和pluginRepositories添加新配置文件。 (settings.xml文件可以存在两个位置:$ M2_HOME / conf / settings.xml或$ {user.home} /.m2 / settings.xml)

<profiles>
     ...
     <profile>
        <id>mule-extra-repos</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>mule-public</id>
                <url> https://repository.mulesoft.org/nexus/content/repositories/public </url>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>mule-public</id>
                <url> https://repository.mulesoft.org/nexus/content/repositories/public </url>
            </pluginRepository>
        </pluginRepositories>
     </profile>
     ...
 </profiles>

步骤2:添加一个新的pluginGroup,如下所示。

<pluginGroups>
    ...
    <pluginGroup>org.mule.tools</pluginGroup>
    ...
 </pluginGroups>

有关详细信息,请访问此页面https://docs.mulesoft.com/mule-user-guide/v/3.7/maven-tools-for-mule-esb

答案 6 :(得分:0)

我认为这是你的mule studio Java设置的问题。 Mule工作室默认指向JRE而不是JDK。 tools.jar在JDK文件夹下可用。请参阅以下链接,该链接告诉您如何将JDK添加到studio然后使用它来构建

http://www.gamefromscratch.com/post/2011/11/15/Telling-Eclipse-to-use-the-JDK-instead-of-JRE.aspx

答案 7 :(得分:0)

我注意到如果您的流程涉及API Kit和Dataweave,则需要添加其他依赖项。

        <plugin>
            <executions>
                <execution>
                    <configuration>
                        <resources>
                            <resource>
                                <directory>src/main/api/</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    <dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-apikit</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.mulesoft.weave</groupId>
        <artifactId>mule-plugin-weave_2.11</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-http</artifactId>
        <version>${mule.version}</version>
        <scope>provided</scope>
    </dependency>

答案 8 :(得分:0)

如果在使用Maven构建项目时遇到Anypoint Studio的以下错误。

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin org.mule.tools.maven:mule-app-maven-plugin:1.2 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:1.5.0 at specified path C:\Program Files\Java\jre1.8.0_162/../lib/tools.jar @ 
[ERROR] Unknown packaging: mule @ line 9, column 16
[WARNING] 'dependencies.dependency.systemPath' for com.sun:tools:jar refers to a non-existing file C:\Program Files\Java\jre1.8.0_162C:\Program Files\Java\jdk1.8.0_162\lib\tools.jar @ line 75, column 21
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.mycompany:maven-test1:1.0.0-SNAPSHOT (C:\Users\Venkata Phanindra\AnypointStudio\workspace\maven-test1\pom.xml) has 2 errors
[ERROR]     Unresolveable build extension: Plugin org.mule.tools.maven:mule-app-maven-plugin:1.2 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:1.5.0 at specified path C:\Program Files\Java\jre1.8.0_162/../lib/tools.jar -> [Help 2]
[ERROR]     Unknown packaging: mule @ line 9, column 16
[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/ProjectBuildingException

[ERROR] [Help 2] 
http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException

请按照以下步骤解决问题

  1. 从Anypoint studio转到Windows->首选项->已安装的JRE。
  2. 在此将JRE(C:\ Program Files \ Java \ jre1.8.0_162)更改为JDK(C:\ Program Files \ Java \ jdk1.8.0_162)并选择JDK复选框,然后单击Finish-> ok- >好的。

现在尝试通过右键单击pom.xml文件Mule->更新项目依赖项来更新pom.xml文件。

如果仍然遇到问题,请执行以下另一步骤:

  1. 转到Windows->首选项->已安装的JRE->执行环境 在这里选择JavaSE-1.8,然后在右窗口上单击jdk1.8.0_162 [完全匹配] 然后尝试更新项目依赖项。

这将解决问题。