Home > Back-end >  Spring Web projects multi module
Spring Web projects multi module

Time:09-08

Regarding modern multi-module constructions.

Can many Spring Web projects be imported into one another?

 - Project 1 ==> have some endpoints 
 - Project 2 ==> have some other
   endpoints

I tried, but only Project 1's endpoints are exposed. and the other project 2 endpoints provide the following error

 The origin server did not find a current representation for the target resource or is not
        willing to disclose that one exists.

project 1 dependencies

api 'org.springframework.boot:spring-boot-starter-security'
api 'org.springframework.boot:spring-boot-starter-actuator'
api("io.springfox:springfox-swagger2:3.0.0") {
    exclude module: "mapstruct"
}
compileOnly 'javax.servlet:servlet-api:2.5'
api 'javax.persistence:javax.persistence-api:2.2'
api 'org.springframework.boot:spring-boot-starter-data-jpa'
api 'com.cmeza:spring-data-generator:1.1.9'
api 'org.springframework.boot:spring-boot-starter-web'

api 'com.slack.api:slack-api-client:1.24.0'
api 'com.google.guava:guava:31.1-jre'
api 'io.jsonwebtoken:jjwt:0.9.1'
api 'org.apache.commons:commons-lang3:3.12.0'
api 'javax.validation:validation-api:2.0.1.Final'
api 'io.jsonwebtoken:jjwt:0.9.1'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

project 2 dependencies

implementation project(":project1")
implementation 'javax.persistence:javax.persistence-api:2.2'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.cmeza:spring-data-generator:1.1.9'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation('javax.xml.bind:jaxb-api:2.3.1')
implementation('org.javassist:javassist:3.23.1-GA')
implementation 'org.mapstruct:mapstruct:1.5.2.Final'
implementation 'com.opencsv:opencsv:5.6'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.2.Final'

CodePudding user response:

I was expecting this will include project 2 packages as it's the main runner

@ComponentScan(basePackages="project1.*")

but, regrettably, it doesn't.

so it should be

@ComponentScan(basePackages="project1.*","project2.*")

  • Related