The Project A(Custom starter) maven as flow
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
The configuration class file is as follows:
@ConditionalOnClass(StringRedisTemplate.class)
@ConditionalOnBean(StringRedisTemplate.class)
@AutoConfigureAfter(value = RedisAutoConfiguration.class,name = {"org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration"})
public class LexiconRedisStrategyConfiguration {
@ConditionalOnBean(LexiconSensitiveWordRepository.class)
@Bean
@ConditionalOnMissingBean
public SensitiveAddStrategy getSensitiveAddStrategy(StringRedisTemplate stringRedisTemplate){
RedisSensitiveAddStrategy redisSensitiveAddStrategy = new RedisSensitiveAddStrategy();
redisSensitiveAddStrategy.setStringRedisTemplate(stringRedisTemplate);
return redisSensitiveAddStrategy;
}
}
the spring.factory
org.springframework.boot.autoconfigure.EnableAutoConfiguration=
xxx.configuration.LexiconRedisStrategyConfiguration
Project B import project A report an error while running:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.<init>()
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:83)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1312)
... 59 common frames omitted
Caused by: java.lang.NoSuchMethodException: org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
Why the mistake?
Comment From: wilkinsona
I'm not sure what the mistake is. Unfortunately, it's hard to tell from code snippets and a truncated stack trace. I doubt that it is due to the use of @AutoConfigureAfter
as we have several auto-configurations in Spring Boot that use @AutoConfigureAfter
to ensure that they're processed after HibernateJpaAutoConfiguration
.
If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Comment From: luoluo001
I'm not sure what the mistake is. Unfortunately, it's hard to tell from code snippets and a truncated stack trace. I doubt that it is due to the use of
@AutoConfigureAfter
as we have several auto-configurations in Spring Boot that use@AutoConfigureAfter
to ensure that they're processed afterHibernateJpaAutoConfiguration
.If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Ok, thank you for your answer. I will upload the project to Github later, and I have finished uploading call to you
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.