I write project using Java
and Maven
. In project I have many modules. My problem is that I can not import classes from other module.
My project structure looks like this:
Project |_ module1 |_ src |_ com.xyz.project.md1 |_ Person.java |_ pom.xml <- pom of module1 |_ module2 |_ src |_ com.xyz.project.md2 |_ Robot.java |_ pom.xml <- pom of module2 |_ pom.xml <- main Project pom
module1
and module2
are Modules
in my project, which are registred in pom.xml
- main Project pom
And when I am in Person.java
from module1
I want import the Robot.java
from module2
but I can not do this with import com.xyz.project.md2.Robot
. Why ?
Such a file is called a module; definitions from a module can be imported into other modules or into the main module (the collection of variables that you have access to in a script executed at the top level and in calculator mode).
The import statement allows you to import one or more modules into your Python program, letting you make use of the definitions constructed in those modules.
Declare dependency to module2 in module1/pom.xml, something like this:
<dependencies> ... <dependency> <groupId>XX</groupId> <artifactId>module2</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> ... </dependencies>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With