Cannot find class from maven dependency project

[CLOSED - I had to move classes from test / java to main / java and update the maven repository through the IDE "maven options"]

I am new to maven and inexperienced with Java development. I am using IntelliJ Idea as an IDE. I am using Maven 3.0.4.

I created "project A" and "project B", each of which has some classes. Now, when I try to create a dependency in project A with a class in the project BI, it seems that I can not find any classes that are part of project B. When I check the maven repository, I see that the .jar file is created based on project B .

To clarify: when adding a dependency to the BI project do, find the artifact called "project B", but I cannot find any classes that are part of project B.

It doesn't seem like I can access and use any of the classes that are part of project B inside project A, which would make this installation useless.

-

Please tell me what information I should provide for you to help me solve this problem.

[EDIT] Here is the A pom project, depending on project B. However, I either donโ€™t understand how to use it in my project, or it doesnโ€™t work. Although I can use IntelliJ to find and add artifacts, intelliJ cannot find any classes that are part of project B (while it finds classes that are part of other predefined packages in the maven repository):

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>planet</groupId> <artifactId>planet</artifactId> <version>1.0</version> <dependencies> <dependency> <groupId>toolbox</groupId> <artifactId>toolbox</artifactId> <version>1.0</version> </dependency> </dependencies> </project> 
+4
source share
2 answers

I had to move my classes from test / java to main / java. Stupid, but it took me a whole day to figure this out. This only worked after updating the repository in the "maven" options through the IDE.

+6
source

You can do the following:

 <dependency> <groupId>toolbox</groupId> <artifactId>toolbox</artifactId> <version>1.0</version> <type>test-jar</type> <scope>test</scope> </dependency> 

It works for me :)

+1
source

Source: https://habr.com/ru/post/1402033/


All Articles