How to make multiple spring boot projects dependency work?

buildship

(Wang Peng) #1

I am just using spring boot initializer to create base and sub two projects and using the most simple multiple projects. directory like below. I set settings.gradle at root to include ‘base’,‘sub’. I also add compile project(’:base’) dependency in sub/gradle.build. When I run gradle build in root folder it will always failed when execute :sub:compileJave and report can’t find some package from base project. And the strange is when I run gradlew :sub:compileJava it will succeed. Any body can tell me what it correct way to make gradlew build work?
root
│ gradlew.bat
│ settings.gradle
├───base
│ │ .gitignore
│ │ build.gradle
│ │ gradlew
│ │ gradlew.bat
│ ├───gradle
│ │ └───wrapper
│ │ gradle-wrapper.jar
│ │ gradle-wrapper.properties
│ │
│ └───src
│ ├───main
│ │ ├───java
│ │ │ └───com
│ │ │ └───example
│ │ │ BaseApplication.java
│ │ │
│ │ └───resources
│ │ application.properties
│ │
│ └───test
│ └───java
│ └───com
│ └───example
│ BaseApplicationTests.java

├───gradle
│ └───wrapper
│ gradle-wrapper.jar
│ gradle-wrapper.properties

└───sub
│ .gitignore
│ build.gradle
│ gradlew
│ gradlew.bat

├───gradle
│ └───wrapper
│ gradle-wrapper.jar
│ gradle-wrapper.properties

└───src
├───main
│ ├───java
│ │ └───com
│ │ └───example
│ │ SubApplication.java
│ │
│ └───resources
│ application.properties

└───test
└───java
└───com
└───example
SubApplicationTests.java


(Wang Peng) #2

I have found root cause. I need to set bootRepackage.enabled=false to avoid package base project to a boot “fat” jar.