Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot upgrade to 1.4 broke my multi module project - probably due to jar layout change

Tags:

spring-boot

I have upgraded to Spring Boot 1.4.0 and my Maven project does not compile. Here is the scenario:

  • Module 1 / Spring Boot
  • Module 2 / Spring Boot with dependency on Module 1

When I compile Module 2, I receive errors that the packages/classes do not exist (they exist in Module 1). Maven correctly set the class patch (jar from target of Module 1 is included).

When I change to Spring Boot 1.3.6, it compiles without any issues.

I checked the release notes for Spring Boot 1.4 and there is no information about any action to be performed in this area.

Have you observed the same behavior with Spring Boot 1.4?

I have such configuration to allow test execution. Both modules are microservices and I have tests for Module 2 which I want to execute without starting Module 1 as separate microservice.

like image 878
Tomek Avatar asked Aug 17 '16 09:08

Tomek


2 Answers

You are using the fat jar of Module 1 as a dependency for Module 2. So you are basically embedding the full app from Module 1 in module 2. You shouldn't do that.

In 1.4, classes have moved to BOOT-INF/classes so they aren't found anymore. I guess that's a nice side effect to let you know that your project setup is broken.

You should generate both a regular jar and an app jar (if you really need to) for module 1. Is module 1 an app? If it isn't, disable the spring-boot-maven-plugin there. If it is, configure the classifier option to generate two jars.

like image 124
Stephane Nicoll Avatar answered Oct 18 '22 19:10

Stephane Nicoll


Change your layout to MODULE, ZIP layout seem to have change in 1.4.x. Zip layout will put all your project classes under BOOT-INF/classe/**, module will put your class on root.

like image 3
Breaut Avatar answered Oct 18 '22 20:10

Breaut