关于现代多模块结构。
许多Spring项目可以相互导入吗?
- Project 1 ==> have some endpoints
- Project 2 ==> have some other
endpoints
我试过了,但是只有项目1的端点暴露了。而其他项目2端点提供了以下错误
The origin server did not find a current representation for the target resource or is not
willing to disclose that one exists.
项目1依赖关系
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'
项目2依赖关系
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'
发布于 2022-08-29 10:41:21
我原以为这将包括项目2包,因为它是主要的运行程序
@ComponentScan(basePackages="project1.*")
但遗憾的是,事实并非如此。
所以它应该是
@ComponentScan(basePackages="project1.*","project2.*")
https://stackoverflow.com/questions/73525689
复制相似问题