Skip to content

Commit

Permalink
✨ Spring boot 2.7.x spi 改为支持 Component
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunMengLu committed Jan 2, 2023
1 parent 719e35f commit 1b6a0af
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ mica auto 采用 Annotation Processor,她不是什么新技术,在 jdk 1.6
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-auto</artifactId>
<version>2.3.1</version>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
```

### gradle >= 5.x
```groovy
annotationProcessor("net.dreamlu:mica-auto:2.3.1")
annotationProcessor("net.dreamlu:mica-auto:2.3.2")
```

### gradle < 5.x
```groovy
compileOnly "net.dreamlu:mica-auto:2.3.1"
compileOnly "net.dreamlu:mica-auto:2.3.2"
```

## 原理
Expand Down
6 changes: 3 additions & 3 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ It is mainly used to avoid the inconsistency between the Spring Boot main projec
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-auto</artifactId>
<version>2.3.1</version>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
```

### gradle >= 5.x
```gradle
annotationProcessor("net.dreamlu:mica-auto:2.3.1")
annotationProcessor("net.dreamlu:mica-auto:2.3.2")
```

### gradle < 5.x
```gradle
compileOnly "net.dreamlu:mica-auto:2.3.1"
compileOnly "net.dreamlu:mica-auto:2.3.2"
```

## Principle
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ apply from: "${rootProject.projectDir}/gradle/publish-maven.gradle"

ext {
javaVersion = JavaVersion.VERSION_1_8
springBootVersion = "2.7.0"
springBootVersion = "2.7.7"
lombokVersion = "1.18.24"
googleAutoVersion = "1.0.1"
compileTestingVersion = "0.19"
compileTestingVersion = '0.21.0'
incapVersion = "0.3"
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=2.3.1
VERSION=2.3.2
GROUPID=net.dreamlu

NEXUS_OSS_USER_NAME=***
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/dreamlu/mica/auto/common/BootAutoType.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum BootAutoType {
/**
* Component,组合注解,添加到 spring.factories
*/
COMPONENT("org.springframework.stereotype.Component", "org.springframework.boot.autoconfigure.EnableAutoConfiguration"),
COMPONENT(BootAutoType.COMPONENT_ANNOTATION, "org.springframework.boot.autoconfigure.EnableAutoConfiguration"),
/**
* ApplicationContextInitializer 添加到 spring.factories
*/
Expand Down Expand Up @@ -90,4 +90,6 @@ public enum BootAutoType {
private final String annotation;
private final String configureKey;

public static final String COMPONENT_ANNOTATION = "org.springframework.stereotype.Component";

}
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ private void processAnnotations(Set<? extends TypeElement> annotations, RoundEnv
log("读取到新配置 spring.factories factoryName:" + factoryName);
factories.put(FEIGN_AUTO_CONFIGURE_KEY, factoryName);
} else {
// 1. 生成 2.7.x 的 @AutoConfiguration
if (isAnnotation(elementUtils, typeElement, AUTO_CONFIGURATION)) {
// 1. 生成 2.7.x 的 spi
if (isAnnotation(elementUtils, typeElement, BootAutoType.COMPONENT_ANNOTATION)) {
String autoConfigurationBeanName = typeElement.getQualifiedName().toString();
autoConfigurationImportsSet.add(autoConfigurationBeanName);
log("读取到自动配置 @AutoConfiguration:" + autoConfigurationBeanName);
Expand Down

0 comments on commit 1b6a0af

Please # to comment.