#spring #spring-boot #gradle
Вопрос:
У меня проблема с многомодульным проектом Spring boot.
у меня есть 1 корневой проект и 3 подмодуля.
root: api
1. module-common
2. module-client
3. module-admin
это мой корень «build.gradle».
plugins {
id 'org.springframework.boot' version '2.5.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
allprojects {
group = 'com.foodzim'
version = '0.0.1-SNAPSHOT'
}
subprojects {
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation:2.5.3'
implementation 'org.springframework.boot:spring-boot-starter-security:2.5.3'
compileOnly 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
// aws
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
// excel
implementation 'org.apache.poi:poi:4.1.2'
implementation 'org.apache.poi:poi-ooxml:4.1.2'
// Database
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.3'
//redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis:2.4.5'
// test
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.3'
testRuntimeOnly 'com.h2database:h2:1.4.200'
}
test {
useJUnitPlatform()
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
}
project(":module-client") {
dependencies {
implementation project(":module-common")
}
}
project(":module-admin") {
dependencies {
implementation project(":module-common")
}
}
модуль-общий «build.gradle»
dependencies {
// spring starter
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.3'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.3'
// JWT
implementation 'io.jsonwebtoken:jjwt-api:0.11.2'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.2'
//queryDSL
implementation 'com.querydsl:querydsl-jpa'
annotationProcessor 'com.querydsl:querydsl-apt:4.2.1:jpa'
annotationProcessor 'javax.annotation:javax.annotation-api'
annotationProcessor 'javax.persistence:javax.persistence-api'
implementation 'com.vladmihalcea:hibernate-types-52:2.12.1'
// xml parser
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.4'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.4'
testImplementation 'com.vladmihalcea:hibernate-types-52:2.12.1'
testImplementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.4'
// test queryDSL
testImplementation 'com.querydsl:querydsl-jpa'
testAnnotationProcessor 'com.querydsl:querydsl-apt'
}
module-client’s «build.gradle»
bootJar {
enabled = false
}
jar {
enabled = true
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.3'
}
module-admin’s «build.gradle»
bootJar {
enabled = false
}
jar {
enabled = true
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web:2.5.3'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.5.3'
}
поэтому я разделил проект на 3 подмодуля и настроил build.gradles.
но когда я запустил проект, появилось это сообщение об ошибке.
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [Application]; nested exception is java.lang.IllegalArgumentException: Could not find class [liquibase.integration.spring.SpringLiquibase]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:189) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.3.jar:2.5.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.3.jar:2.5.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.3.jar:2.5.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.3.jar:2.5.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.3.jar:2.5.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.3.jar:2.5.3]
at Application.main(Application.java:17) ~[main/:na]
Caused by: java.lang.IllegalArgumentException: Could not find class [liquibase.integration.spring.SpringLiquibase]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:334) ~[spring-core-5.3.9.jar:5.3.9]
at org.springframework.core.annotation.TypeMappedAnnotation.adapt(TypeMappedAnnotation.java:446) ~[spring-core-5.3.9.jar:5.3.9]
at org.springframework.core.annotation.TypeMappedAnnotation.getValue(TypeMappedAnnotation.java:369) ~[spring-core-5.3.9.jar:5.3.9]
at org.springframework.core.annotation.TypeMappedAnnotation.asMap(TypeMappedAnnotation.java:284) ~[spring-core-5.3.9.jar:5.3.9]
at org.springframework.core.annotation.AbstractMergedAnnotation.asAnnotationAttributes(AbstractMergedAnnotation.java:193) ~[spring-core-5.3.9.jar:5.3.9]
at org.springframework.core.type.AnnotatedTypeMetadata.getAnnotationAttributes(AnnotatedTypeMetadata.java:106) ~[spring-core-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.AnnotationConfigUtils.attributesFor(AnnotationConfigUtils.java:285) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.AnnotationBeanNameGenerator.determineBeanNameFromAnnotation(AnnotationBeanNameGenerator.java:102) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.AnnotationBeanNameGenerator.generateBeanName(AnnotationBeanNameGenerator.java:81) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:280) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:296) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:207) ~[spring-context-5.3.9.jar:5.3.9]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:175) ~[spring-context-5.3.9.jar:5.3.9]
... 13 common frames omitted
Caused by: java.lang.ClassNotFoundException: liquibase.integration.spring.SpringLiquibase
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
at java.base/java.lang.Class.forName0(Native Method) ~[na:na]
at java.base/java.lang.Class.forName(Class.java:398) ~[na:na]
at org.springframework.util.ClassUtils.forName(ClassUtils.java:284) ~[spring-core-5.3.9.jar:5.3.9]
at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:324) ~[spring-core-5.3.9.jar:5.3.9]
... 27 common frames omitted
Есть ли какое-либо решение для решения этой проблемы??
Комментарии:
1. попробуйте добавить org.liquibase:liquibase-core в качестве зависимости от реализации модуля-администратора
2. все та же проблема.
3. В каком проекте были созданы журналы ошибок? Вы добавили какие-либо настройки, связанные с Liquibase, в свои настройки
application.yml/properties
, не включая зависимости от Liquibase?4. Если вы добавили новые зависимости, обязательно обновите
build.gradle
s. Добавьтеapplication.yml
также свои настройки.5. я решил эту проблему. это была проблема buidl.gradle. я не соответствую зависимостям. Спасибо