Maven 构建失败:包不存在 [英] Maven build failure: package does not exist

查看:55
本文介绍了Maven 构建失败:包不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 Maven 模块,AppManager 和 myApp.它们在本地位于同一目录中,并且在公司的在线存储库中不可用,因为它们用于测试目的.在 IntelliJ 中,我使用 AppManager 的字段和方法没有问题,并且没有错误消息.我正在为 myApp 在我的 impl pom 文件中导出 com.mycompany.appManager.但是,当我在 IDE 之外构建时,即 mvn clean install,会出现包 com.mycompany.appManager 不存在的错误,然后关联未解决的错误appManager 中定义的公共字段的使用符号.我该如何解决这个问题?我已经尝试导出并添加依赖项,但这两种解决方案都不起作用.

I have two maven modules, AppManager and myApp. These are in the same directory locally and are not available in the company's online repo as they are for testing purposes. In IntelliJ I have no problem using the fields and methods of AppManager and there are no error messages. I am exporting com.mycompany.appManager in my impl pom file for myApp. However, when I build outside of the IDE, i.e. mvn clean install, there is an error for the package com.mycompany.appManager does not exist and then associated errors for unresolved symbols for usage of public fields defined in appManager. How can I resolve this problem? I've tried the exporting and adding a dependency, but these two solutions do not work.

pom.xml:

<moduleVersion>4.0.0</moduleVersion>
<parent>
    <groupId>com.myCompany</groupId>
    <artifactId>myApp</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<groupId>com.myCompany.myApp</groupId>
<artifactId>com.myCompany.myApp.impl</artifactId>
<packaging>bundle</packaging>
<name>My App Implementation</name>

<build>
    <plugins>
        <plugin>
             <groupId>org.apache.felix</groupId>
             <artifactId>maven-bundle-plugin</artifactId>
             <extensions>true</extensions>
             <configuration>
                 <instructions>
                     <Export-Package>
                          com.myCompany.appmanager
                     </Export-Package>
                     <Bundle-Activator>com.mycompany.myapp.impl.component</Bundle-Activator>
                 </instructions>
             </configuration>
         </plugin>
     </plugin>
 </build>

编译错误:

[ERROR] /root/Desktop/apps/myapp/impl/src/main/java/com/mycompany/myApp/impl/component.java:[11,49] package com.mycompany.appmanager does not exist
[ERROR] /root/Desktop/apps/myapp/impl/src/main/java/com/mycompany/myApp/impl/component.java:[64,49] cannot find symbol
    symbol: variable AppManagerModule
    location: class com/mycompany/myApp/impl/component

推荐答案

我尽量回答我所理解的问题:

I try to answer the question as far as I understand it:

如果你有两个项目 A 和 B 并且 A 依赖于 B,那么你必须先构建 B.如果你例如使用 mvn clean install,然后 B.jar 将被放入您的本地存储库.之后,您可以针对它构建 A(如果您在 pom 中选择了正确的版本).

If you have two projects A and B and A depends on B, then you have to have to build B first. If you e.g. use mvn clean install, then B.jar will be put into your local repository. After that, you can build A against it (if you choose the correct version in the pom).

这篇关于Maven 构建失败:包不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆