简体   繁体   English

Maven问题与2个独立项目之间的依赖关系

[英]Maven problem with dependencies between 2 seperate projects

so I have to project having the same groupId but each with a different artifactId. 所以我必须投影具有相同的groupId,但每个项目具有不同的artifactId。 The first project is called persistence and doesn't have any dependencies and the other is called core and needs to depend on persistence. 第一个项目称为持久性,没有任何依赖性,另一个项目称为核心,需要依赖于持久性。 I did a clean install on the persistence project and I can see it was added to my local repo (.m2 directory). 我在持久性项目上进行了全新安装,可以看到它已添加到我的本地存储库(.m2目录)中。 In the pom of the core I can add a dependency on persistence with no problems but whenever I try to use any classes from it I can't seem to import them, the ide simply can'y find them and if I do a import cbs.... then I have a symbol not found error. 在核心的pom中,我可以毫无问题地添加对持久性的依赖,但是每当我尝试从中使用任何类时,我似乎都无法导入它们,ide根本找不到它们,如果我执行导入cbs ....那么我有一个找不到符号的错误。

Here is the pom files: 这是pom文件:

persistence 坚持不懈

<groupId>cbs</groupId>
<artifactId>persistence</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>

Code: 码:

<groupId>cbs</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>

<dependencies>
    <dependency>
        <groupId>com.pi4j</groupId>
        <artifactId>pi4j-core</artifactId>
        <version>LATEST</version>
    </dependency>

    <dependency>
        <groupId>com.fazecast</groupId>
        <artifactId>jSerialComm</artifactId>
        <version>LATEST</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.16</version>
    </dependency>

    <dependency>
        <groupId>cbs</groupId>
        <artifactId>persistence</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

</dependencies>

Ok nevermind I just found out my packages where messed up and the java classes of persistence were totally outside the packages. 好的,没关系,我只是发现我的程序包混乱不堪,而java持久性类完全不在程序包之内。 So if anyone is having this issue it could be that the class you re trying to import is directly inside the src folder and not in any package. 因此,如果有人遇到此问题,则可能是您尝试导入的类直接在src文件夹内,而不在任何包中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM