Gradle multi-module Springboot project compile project references the pits of other modules

 

I originally thought that the compile project(':xxx') in the subproject could reference other modules, because the idea was not marked in red afterwards.

However, when I build gradle, I can't find all kinds of classes that reference modules.

Finally, I saw similar on stackoverflow, saying that sourceSets should be added to the corresponding submodule

After tinkering for a long time, finally...

Add the following code at the end of the submodule build.gradle

sourceSets {
    main {
        java {
            srcDirs = ['src/main/java','../(another submodule)/src/main/java']
        }
    }
}
jar {
    manifest {
        attributes'Main-Class':'Main-class of the project'
    }
}

Guess you like

Origin blog.csdn.net/u012452555/article/details/81871063