I wrote a module. In pom.xml, I use the spring-boot configuration to build the project:

<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven.version}</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.0.4.RELEASE</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> <configuration> <mainClass>ru.Main</mainClass> </configuration> </execution> </executions> </plugin> </plugins> <resources> <resource> <directory>${project.basedir}/src/main/resources</directory> </resource> </resources> </build> 

Once in IDEA I execute install jar-nickname gets into the local repository of mavena .m2 / repository /

After that, I add a dependency to my package in a new project in pom.xml:

  <dependency> <groupId>ru.bityard.asterisk</groupId> <artifactId>ami</artifactId> <version>1.0.0</version> </dependency> 

IDEA sees it, and loads it.

Now I am trying to create an instance of a class from this package and it does not work ... And does IDEA itself ask to add import to the package? I agree and nothing happens ...

screen IDEA

I'm trying to prescribe the way

 import ru.bityard.asterisk 

but IDEA does not see it ...

I looked that in all packages loaded by maven, the class path starts from the root of the package, for example:

 org/springframework/... 

and in my package, the path begins

 BOOT-INF/classes/ru/... 

Maybe this is the case? Help me to understand.

  • jar got into local .m2 repository? - Stranger in the Q
  • @StrangerintheQ yes, of course. And his IDEA sees and pulls up when I specify it in pom.xml. I attached a screenshot in the post. There you can see that the package was pulled up depending on - Vitaly M.

1 answer 1

It's simple, spring-boot-maven-plugin builds a spring-boot application - this is the final product. You also need ami to be an API for another project.

Here are some solutions, for example, to add a classifier

 <configuration> <mainClass>ru.Main</mainClass> <classifier>spring-boot</classifier> </configuration> 

then during the build two jar: ami.jar and ami-spring-boot.jar will be created during install / deploy , only ami.jar will get into the repository - this is just an API for other projects.

  • Thank you very much! - Vitaly M.