Maven dependencies not active for packages in src/java/main

Answered

I have got a java class inside of a package for better structure. In my POM I have added in the dependency to another maven module. When my file is inside the package intellij cannot resolve the object. When I move the class outside of the package it works all of a sudden. How do I get the dependency to work inside the package as well? Do I need to add something to the POM?

0
4 comments

> have got a java class inside of a package 

>POM I have added in the dependency to another maven module

To another module than where the class is declared?

>When my file is inside the package intellij cannot resolve the object.

What is the exact object? Does Maven build work from command line?

>How do I get the dependency to work inside the package as well?

Have you added import statement to the class?

Please provide a sample project for faster troubleshooting if problem remains.

0

I have created a sample project that can be viewed here:

https://github.com/Erik-Henriksson/DependencyError

 

I want to use CodeObject in LogicCode1 within Package1 but it does not seem to work. For code outside the package, such as in LogicCode2 I can create the object. How do I resolve this?

0

Thank you. You can’t use classes in the default package (no package name) from a named package. You need to mode the class into a package to use it as a dependency. Please see this thread: https://stackoverflow.com/q/283816/2000323

0

Thank you so much for the help! :)

0

Please sign in to leave a comment.