Compare commits
55 Commits
Author | SHA1 | Date |
---|---|---|
|
08657b90b3 | |
|
eaf15a6e6e | |
|
5a97a9dd6b | |
|
6c29062a1c | |
|
a5aa9f70bb | |
|
82caa209b3 | |
|
71db41f853 | |
|
a5ba72ac01 | |
|
df0f68fcfa | |
|
7144598c21 | |
|
c080c91c15 | |
|
8b2621bc29 | |
|
6b626f364c | |
|
6771d1b311 | |
|
008ae0bce7 | |
|
a9d0ea104a | |
|
c682961079 | |
|
af106fc5da | |
|
3e50f33fe7 | |
|
b1a19f679f | |
|
e5ada95281 | |
|
3ecc302443 | |
|
04e84c2b42 | |
|
02236568b4 | |
|
b6da64e902 | |
|
f0cc777109 | |
|
35e9c3e7c1 | |
|
40035fa032 | |
|
2d257777c2 | |
|
f9efddfb44 | |
|
ca9a90543a | |
|
979c01702d | |
|
a09746f41e | |
|
bfecd49e33 | |
|
cd810f4d25 | |
|
aec14871ca | |
|
9a27a58a00 | |
|
e725f83cdc | |
|
d1575460b8 | |
|
b2649223da | |
|
1ef681c7d6 | |
|
e54e0cdd0d | |
|
a8d6a80dd8 | |
|
dbde2edc24 | |
|
147829ac05 | |
|
a981cc9de9 | |
|
0bf34babc6 | |
|
3e70665970 | |
|
f9c1d281ad | |
|
03ec22f997 | |
|
ed5843c16b | |
|
f401521964 | |
|
1bdd5a2e1a | |
|
b2fb611d4c | |
|
b87a4136f0 |
|
@ -0,0 +1,206 @@
|
|||
## Nacos AOT
|
||||
|
||||
### prerequisites
|
||||
|
||||
- GraalVM22.0+ (JDK17)
|
||||
- native-image
|
||||
- Nacos Server
|
||||
|
||||
If you haven't downloaded GraalVM, you can download it from [Download GraalVM](https://www.graalvm.org/downloads/).
|
||||
|
||||
If you don't have a native-image environment, you can configure according to [Native Image](https://www.graalvm.org/latest/reference-manual/native-image/).
|
||||
|
||||
You have to start a Nacos Server in backend , If you don't know steps, you can learn about [quick start](https://nacos.io/en-us/docs/quick-start.html).
|
||||
|
||||
### Quick Start
|
||||
|
||||
The complete code for this example can be found at: [`nacos-aot-sample`](nacos-spring-boot-samples/nacos-aot-sample)
|
||||
|
||||
1. Because SpringBoot2 does not support aot, you must specify SpringBoot as SpringBoot3 in dependency management:
|
||||
|
||||
```xml
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
```
|
||||
|
||||
2. You would add [`nacos-config-spring-boot-starter`](nacos-config-spring-boot-starter) or [`nacos-discovery-spring-boot-starter`](nacos-discovery-spring-boot-starter) in your Spring application's dependencies :
|
||||
|
||||
```xml
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
||||
<version>${latest.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-discovery-spring-boot-starter</artifactId>
|
||||
<version>${latest.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
3. In order to use the process-aot feature of SpringBoot and more conveniently compile native-image programs, we also need `spring-boot-maven-plugin` and `native-maven-plugin`:
|
||||
|
||||
```xml
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>native</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.graalvm.buildtools</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
<version>0.9.25</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
|
||||
<mainClass>com.alibaba.boot.nacos.sample.AotApplication</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>process-aot</id>
|
||||
<goals>
|
||||
<goal>process-aot</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
```
|
||||
|
||||
4. You could define some configurations in `application.properties`:
|
||||
|
||||
```properties
|
||||
nacos.config.server-addr=localhost:8848
|
||||
nacos.discovery.server-addr=localhost:8848
|
||||
```
|
||||
|
||||
> `nacos.config.server-addr` and `nacos.discovery.server-addr` attribute configure "\${host}:${port}" of your Nacos Server
|
||||
|
||||
5. You could using `@SpringBootApplication` to annotate main class like normal SpringBoot Application and startup:
|
||||
|
||||
```java
|
||||
@SpringBootApplication
|
||||
@NacosPropertySource(dataId = "example", autoRefreshed = true)
|
||||
public class AotApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AotApplication.class, args);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Note: `@NacosPropertySource` is used to specify the data-id of the configuration.
|
||||
|
||||
6. Let's try the functions of `@NacosInjected` and `@NacosValue`, for more usage, see [Nacos Spring Project](https://github.com/nacos-group/nacos-spring-project).
|
||||
|
||||
```java
|
||||
@Controller
|
||||
public class AotController {
|
||||
@NacosInjected
|
||||
private ConfigService configService;
|
||||
|
||||
@NacosInjected
|
||||
private NamingService namingService;
|
||||
|
||||
@NacosValue(value = "${flag:false}", autoRefreshed = true)
|
||||
private boolean flag;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/config/get", method = GET)
|
||||
public String getConfig() throws NacosException {
|
||||
return configService.getConfig("example", "DEFAULT_GROUP", 5000);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/naming/get", method = GET)
|
||||
public List<Instance> getNaming(@RequestParam("serviceName") String serviceName) throws NacosException {
|
||||
return namingService.getAllInstances(serviceName);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/flag/get", method = GET)
|
||||
public boolean getFlag() {
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
7. Publish the configuration to the Nacos Server by calling the Nacos Open API, with dataId of example and content of `flag=true`
|
||||
|
||||
```shell
|
||||
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=example&group=DEFAULT_GROUP&content=flag=true"
|
||||
```
|
||||
|
||||
8. Enable the tracing agent on the command line with the `java` command from the GraalVM JDK:
|
||||
|
||||
```shell
|
||||
$JAVA_HOME/bin/java -agentlib:native-image-agent=config-output-dir=/path/to/config-dir/ ...
|
||||
```
|
||||
|
||||
Note: For more information about tracing agent, see [Collect Metadata with the Tracing Agent](https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/).
|
||||
|
||||
9. Run the java program and follow the steps below to use the program:
|
||||
|
||||
1. Open `localhost:8080/config/get` with a browser, and the browser responds with `flag=true`.
|
||||
2. Open `localhost:8080/flag/get` with a browser, and the browser responds with `true`.
|
||||
3. Publish the configuration to the Nacos Server by calling the Nacos Open API, with dataId of example and content of `flag=false`
|
||||
|
||||
```shell
|
||||
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=example&group=DEFAULT_GROUP&content=flag=false"
|
||||
```
|
||||
|
||||
4. Open `localhost:8080/flag/get` with a browser, and the browser responds with `false`.
|
||||
5. Register a service named example with Nacos server by calling Nacos Open API.
|
||||
|
||||
```shell
|
||||
curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=example&ip=127.0.0.1&port=8080'
|
||||
```
|
||||
|
||||
6. Open `localhost:8080/naming/get?serviceName=example` with a browser, and the browser responds with information about the service you just registered.
|
||||
|
||||
10. Close the program and copy the file just generated to the `classpath:META-INF/native-image/` folder, The file path is specified in step 8.
|
||||
|
||||
Note: [`nacos-aot-sample`](nacos-spring-boot-samples/nacos-aot-sample) already includes these files, but you can still use the files you just generated.
|
||||
|
||||
11. Run the following command and you will find the compiled executable program in the `target` folder.
|
||||
|
||||
```shell
|
||||
mvn -DskipTests=true clean package -Pnative
|
||||
```
|
||||
|
||||
12. This executable program is what we want! Run the program and try step 9 again.
|
||||
|
||||
## Relative Projects
|
||||
|
||||
* [Alibaba Nacos](https://github.com/alibaba/nacos)
|
||||
* [Alibaba Spring Context Support](https://github.com/alibaba/spring-context-support)
|
||||
* [Nacos Spring Project](https://github.com/nacos-group/nacos-spring-project)
|
||||
* [Nacos Spring Cloud Project](https://github.com/spring-cloud-incubator/spring-cloud-alibaba)
|
|
@ -18,10 +18,10 @@ Suppose your Nacos Server is startup, you would add [`nacos-config-spring-boot-s
|
|||
</dependencies>
|
||||
```
|
||||
|
||||
Note: Version [0.2.x.RELEASE](https://mvnrepository.com/artifact/com.alibaba.boot/nacos-config-spring-boot-starter) is compatible with the Spring Boot 2.x. Version [0.1.x.RELEASE](https://mvnrepository.com/artifact/com.alibaba.boot/nacos-config-spring-boot-starter) is compatible with the Spring Boot 1.x.
|
||||
Note: Version [0.2.x.RELEASE](https://mvnrepository.com/artifact/com.alibaba.boot/nacos-config-spring-boot-starter) is compatible with the Spring Boot 2.x and the Spring Boot 3.x. Version [0.1.x.RELEASE](https://mvnrepository.com/artifact/com.alibaba.boot/nacos-config-spring-boot-starter) is compatible with the Spring Boot 1.x.
|
||||
|
||||
After that, you could define some configurations in `application.properties`:
|
||||
|
||||
|
||||
```properties
|
||||
nacos.config.server-addr=localhost:8848
|
||||
```
|
||||
|
@ -98,7 +98,7 @@ Then Configure your endpoint security strategy.
|
|||
management.security.enabled=false
|
||||
```
|
||||
|
||||
* Spring Boot2.x
|
||||
* Spring Boot2.x or Spring Boot3.x
|
||||
|
||||
```properties
|
||||
management.endpoints.web.exposure.include=*
|
||||
|
@ -107,7 +107,7 @@ management.endpoints.web.exposure.include=*
|
|||
To view the endpoint information, visit the following URLS:
|
||||
|
||||
* Spring Boot1.x: URL is http://127.0.0.1:10011/nacos-config.
|
||||
* Spring Boot2.x: URL is http://127.0.0.1:10011/actuator/nacos-config.
|
||||
* Spring Boot2.x or Spring Boot3.x: URL is http://127.0.0.1:10011/actuator/nacos-config.
|
||||
|
||||
## Health Checks
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ Suppose your Nacos Server is startup, you would add [`nacos-discovery-spring-boo
|
|||
</dependencies>
|
||||
```
|
||||
|
||||
Note: Version [0.2.x.RELEASE](https://mvnrepository.com/artifact/com.alibaba.boot/nacos-discovery-spring-boot-starter) is compatible with the Spring Boot 2.x. Version [0.1.x.RELEASE](https://mvnrepository.com/artifact/com.alibaba.boot/nacos-discovery-spring-boot-starter) is compatible with the Spring Boot 1.x.
|
||||
Note: Version [0.2.x.RELEASE](https://mvnrepository.com/artifact/com.alibaba.boot/nacos-discovery-spring-boot-starter) is compatible with the Spring Boot 2.x and the Spring Boot 3.x. Version [0.1.x.RELEASE](https://mvnrepository.com/artifact/com.alibaba.boot/nacos-discovery-spring-boot-starter) is compatible with the Spring Boot 1.x.
|
||||
|
||||
After that, you could define some configurations in `application.properties`:
|
||||
|
||||
|
||||
```properties
|
||||
nacos.discovery.server-addr=localhost:8848
|
||||
```
|
||||
|
@ -93,7 +93,7 @@ Then Configure your endpoint security strategy.
|
|||
management.security.enabled=false
|
||||
```
|
||||
|
||||
* Spring Boot2.x
|
||||
* Spring Boot2.x or Spring Boot3.x
|
||||
|
||||
```properties
|
||||
management.endpoints.web.exposure.include=*
|
||||
|
@ -102,7 +102,7 @@ management.endpoints.web.exposure.include=*
|
|||
To view the endpoint information, visit the following URLS:
|
||||
|
||||
* Spring Boot1.x: URL is http://127.0.0.1:10012/nacos-discovery.
|
||||
* Spring Boot2.x: URL is http://127.0.0.1:10012/actuator/nacos-discovery.
|
||||
* Spring Boot2.x or Spring Boot3.x: URL is http://127.0.0.1:10012/actuator/nacos-discovery.
|
||||
|
||||
## Health Checks
|
||||
|
||||
|
|
|
@ -18,12 +18,16 @@ Nacos Spring Boot Project consist of two parts: `nacos-config-spring-boot` and `
|
|||
|
||||
`nacos-discovery-spring-boot` module is using for Service Discovery, Service Health Check and Dynamic DNS Service.
|
||||
|
||||
Additionally, Nacos Spring Boot Project already supports native-image.
|
||||
|
||||
## Samples
|
||||
|
||||
- [Nacos Config Sample](https://github.com/nacos-group/nacos-spring-boot-project/tree/master/nacos-spring-boot-samples/nacos-config-sample)
|
||||
|
||||
- [Nacos Discovery Sample](https://github.com/nacos-group/nacos-spring-boot-project/tree/master/nacos-spring-boot-samples/nacos-discovery-sample)
|
||||
|
||||
- [Nacos AOT Sample](https://github.com/nacos-group/nacos-spring-boot-project/tree/master/nacos-spring-boot-samples/nacos-aot-sample)
|
||||
|
||||
## Dependencies & Compatibility
|
||||
|
||||
**Version: 0.2.x / 2.x.x ( branch master )**
|
||||
|
@ -34,7 +38,6 @@ Nacos Spring Boot Project consist of two parts: `nacos-config-spring-boot` and `
|
|||
| Spring Boot | 2.0.3.RELEASE |
|
||||
| Nacos-Spring-Context | 1.1.0 |
|
||||
|
||||
|
||||
**Version: 0.1.x / 1.x.x ( branch: 1.x )**
|
||||
|
||||
| Dependencies | Compatibility |
|
||||
|
@ -51,9 +54,12 @@ Nacos Spring Boot Project consist of two parts: `nacos-config-spring-boot` and `
|
|||
|
||||
- [Nacos Discovery Quick Start](https://github.com/nacos-group/nacos-spring-boot-project/blob/master/NACOS-DISCOVERY-QUICK-START.md)
|
||||
|
||||
- [Nacos AOT Quick Start](https://github.com/nacos-group/nacos-spring-boot-project/blob/master/NACOS-AOT-QUICK-START.md)
|
||||
|
||||
|
||||
For more information about Nacos Spring, see [Nacos Spring Project](https://github.com/nacos-group/nacos-spring-project).
|
||||
|
||||
For more information about user guide, see [User Guide](https://github.com/nacos-group/nacos-spring-boot-project/wiki/%E7%94%A8%E6%88%B7%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3).
|
||||
## Relative Projects
|
||||
|
||||
* [Alibaba Nacos](https://github.com/alibaba/nacos)
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
package com.alibaba.boot.nacos.actuate.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.actuate.endpoint.NacosConfigEndpoint;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -35,7 +34,7 @@ public class NacosConfigEndpointAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
@ConditionalOnAvailableEndpoint
|
||||
public NacosConfigEndpoint nacosEndpoint() {
|
||||
return new NacosConfigEndpoint();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
[
|
||||
{
|
||||
"name": "org.springframework.core.env.ConfigurableEnvironment",
|
||||
"allDeclaredMethods": true,
|
||||
"allDeclaredFields": true,
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicMethods": true,
|
||||
"allPublicFields": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "java.util.Properties",
|
||||
"allDeclaredMethods": true,
|
||||
"allDeclaredFields": true,
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicMethods": true,
|
||||
"allPublicFields": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "org.springframework.core.type.AnnotationMetadata",
|
||||
"allDeclaredMethods": true,
|
||||
"allDeclaredFields": true,
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicMethods": true,
|
||||
"allPublicFields": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "com.alibaba.nacos.api.config.annotation.NacosConfigListener",
|
||||
"allDeclaredMethods": true,
|
||||
"allDeclaredFields": true,
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicMethods": true,
|
||||
"allPublicFields": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "com.alibaba.nacos.api.config.annotation.NacosConfigurationProperties",
|
||||
"allDeclaredMethods": true,
|
||||
"allDeclaredFields": true,
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicMethods": true,
|
||||
"allPublicFields": true,
|
||||
"allPublicConstructors": true
|
||||
},
|
||||
{
|
||||
"name": "org.w3c.dom.Element",
|
||||
"allDeclaredMethods": true,
|
||||
"allDeclaredFields": true,
|
||||
"allDeclaredConstructors": true,
|
||||
"allPublicMethods": true,
|
||||
"allPublicFields": true,
|
||||
"allPublicConstructors": true
|
||||
}
|
||||
]
|
|
@ -0,0 +1,2 @@
|
|||
com.alibaba.boot.nacos.actuate.autoconfigure.NacosConfigEndpointAutoConfiguration
|
||||
com.alibaba.boot.nacos.actuate.autoconfigure.NacosConfigHealthIndicatorAutoConfiguration
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.actuate.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.actuate.endpoint.NacosConfigEndpoint;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* {@link NacosConfigEndpointAutoConfiguration} Test
|
||||
* @ClassName: NacosConfigEndpointAutoConfigurationTest
|
||||
* @Author: SuperZ1999
|
||||
* @Date: 2023/9/28
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = {NacosConfigEndpointAutoConfiguration.class})
|
||||
@TestPropertySource(properties = {
|
||||
"management.endpoints.web.exposure.include=nacos-config"
|
||||
})
|
||||
public class NacosConfigEndpointAutoConfigurationTest {
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testNacosConfigEndpointBean() {
|
||||
Assert.assertNotNull(context.getBean(NacosConfigEndpoint.class));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.actuate.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.actuate.health.NacosConfigHealthIndicator;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* {@link NacosConfigHealthIndicatorAutoConfiguration} Test
|
||||
* @ClassName: NacosConfigHealthIndicatorAutoConfigurationTest
|
||||
* @Author: SuperZ1999
|
||||
* @Date: 2023/9/28
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = {NacosConfigHealthIndicatorAutoConfiguration.class})
|
||||
public class NacosConfigHealthIndicatorAutoConfigurationTest {
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testNacosConfigHealthIndicatorBean() {
|
||||
Assert.assertNotNull(context.getBean(NacosConfigHealthIndicator.class));
|
||||
}
|
||||
}
|
|
@ -87,6 +87,12 @@
|
|||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-spring-boot-aot</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Test Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -21,9 +21,11 @@ import java.util.function.Function;
|
|||
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoader;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoaderFactory;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigPropertiesUtils;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.client.config.utils.SnapShotSwitch;
|
||||
import com.alibaba.nacos.spring.factory.CacheableEventPublishingNacosServiceFactory;
|
||||
import com.alibaba.nacos.spring.util.NacosBeanUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -69,8 +71,12 @@ public class NacosConfigApplicationContextInitializer
|
|||
environment = context.getEnvironment();
|
||||
nacosConfigProperties = NacosConfigPropertiesUtils
|
||||
.buildNacosConfigProperties(environment);
|
||||
final NacosConfigLoader configLoader = new NacosConfigLoader(
|
||||
nacosConfigProperties, environment, builder);
|
||||
final NacosConfigLoader configLoader = NacosConfigLoaderFactory.getSingleton(builder);
|
||||
|
||||
if (!processor.snapshotEnable()){
|
||||
SnapShotSwitch.setIsSnapShot(false);
|
||||
}
|
||||
|
||||
if (!enable()) {
|
||||
logger.info("[Nacos Config Boot] : The preload configuration is not enabled");
|
||||
}
|
||||
|
@ -85,17 +91,10 @@ public class NacosConfigApplicationContextInitializer
|
|||
.addListenerIfAutoRefreshed(processor.getDeferPropertySources());
|
||||
}
|
||||
else {
|
||||
configLoader.loadConfig();
|
||||
configLoader.loadConfig(environment, nacosConfigProperties);
|
||||
configLoader.addListenerIfAutoRefreshed();
|
||||
}
|
||||
}
|
||||
|
||||
final ConfigurableListableBeanFactory factory = context.getBeanFactory();
|
||||
if (!factory
|
||||
.containsSingleton(NacosBeanUtils.GLOBAL_NACOS_PROPERTIES_BEAN_NAME)) {
|
||||
factory.registerSingleton(NacosBeanUtils.GLOBAL_NACOS_PROPERTIES_BEAN_NAME,
|
||||
configLoader.buildGlobalNacosProperties());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean enable() {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package com.alibaba.boot.nacos.config.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.aot.context.EnableNacosConfigAotProcessor;
|
||||
import com.alibaba.boot.nacos.config.NacosConfigConstants;
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.nacos.spring.context.annotation.config.EnableNacosConfig;
|
||||
|
@ -38,7 +39,7 @@ import static com.alibaba.nacos.spring.util.NacosBeanUtils.CONFIG_GLOBAL_NACOS_P
|
|||
@ConditionalOnMissingBean(name = CONFIG_GLOBAL_NACOS_PROPERTIES_BEAN_NAME)
|
||||
@EnableConfigurationProperties(value = NacosConfigProperties.class)
|
||||
@ConditionalOnClass(name = "org.springframework.boot.context.properties.bind.Binder")
|
||||
@Import(value = { NacosConfigBootBeanDefinitionRegistrar.class })
|
||||
@Import(value = { NacosConfigBootBeanDefinitionRegistrar.class, EnableNacosConfigAotProcessor.class })
|
||||
@EnableNacosConfig
|
||||
public class NacosConfigAutoConfiguration {
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@ import java.util.function.Function;
|
|||
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoader;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoaderFactory;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigPropertiesUtils;
|
||||
import com.alibaba.boot.nacos.config.util.log.LogAutoFreshProcess;
|
||||
import com.alibaba.nacos.api.NacosFactory;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
|
@ -54,11 +56,12 @@ public class NacosConfigEnvironmentProcessor
|
|||
.getSingleton();
|
||||
private final Map<String, ConfigService> serviceCache = new HashMap<>(8);
|
||||
private final LinkedList<NacosConfigLoader.DeferNacosPropertySource> deferPropertySources = new LinkedList<>();
|
||||
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
// Because ApplicationContext has not been injected at preload time, need to manually
|
||||
// cache the created Service to prevent duplicate creation
|
||||
private Function<Properties, ConfigService> builder = properties -> {
|
||||
private final Function<Properties, ConfigService> builder = properties -> {
|
||||
try {
|
||||
final String key = NacosUtils.identify(properties);
|
||||
if (serviceCache.containsKey(key)) {
|
||||
|
@ -84,14 +87,14 @@ public class NacosConfigEnvironmentProcessor
|
|||
if (enable()) {
|
||||
System.out.println(
|
||||
"[Nacos Config Boot] : The preload log configuration is enabled");
|
||||
loadConfig(environment);
|
||||
NacosConfigLoader nacosConfigLoader = NacosConfigLoaderFactory.getSingleton(builder);
|
||||
loadConfig(nacosConfigLoader, environment, nacosConfigProperties);
|
||||
LogAutoFreshProcess.build(environment, nacosConfigProperties, nacosConfigLoader, builder).process();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadConfig(ConfigurableEnvironment environment) {
|
||||
NacosConfigLoader configLoader = new NacosConfigLoader(nacosConfigProperties,
|
||||
environment, builder);
|
||||
configLoader.loadConfig();
|
||||
private void loadConfig(NacosConfigLoader configLoader, ConfigurableEnvironment environment, NacosConfigProperties nacosConfigProperties) {
|
||||
configLoader.loadConfig(environment, nacosConfigProperties);
|
||||
// set defer NacosPropertySource
|
||||
deferPropertySources.addAll(configLoader.getNacosPropertySources());
|
||||
}
|
||||
|
@ -101,6 +104,11 @@ public class NacosConfigEnvironmentProcessor
|
|||
&& nacosConfigProperties.getBootstrap().isLogEnable();
|
||||
}
|
||||
|
||||
boolean snapshotEnable() {
|
||||
return nacosConfigProperties != null
|
||||
&& nacosConfigProperties.getBootstrap().isSnapshotEnable();
|
||||
}
|
||||
|
||||
LinkedList<NacosConfigLoader.DeferNacosPropertySource> getDeferPropertySources() {
|
||||
return deferPropertySources;
|
||||
}
|
||||
|
@ -118,7 +126,7 @@ public class NacosConfigEnvironmentProcessor
|
|||
serviceCache.clear();
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("publish defer ConfigService has some error : {}", e);
|
||||
logger.error("publish defer ConfigService has some error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ import com.alibaba.nacos.api.config.ConfigService;
|
|||
import com.alibaba.nacos.api.config.annotation.NacosConfigurationProperties;
|
||||
import com.alibaba.nacos.spring.context.properties.config.NacosConfigurationPropertiesBinder;
|
||||
import com.alibaba.nacos.spring.core.env.NacosPropertySource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata;
|
||||
import com.alibaba.nacos.spring.util.ObjectUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.boot.context.properties.bind.Bindable;
|
||||
import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
@ -39,44 +39,51 @@ import org.springframework.core.env.StandardEnvironment;
|
|||
public class NacosBootConfigurationPropertiesBinder
|
||||
extends NacosConfigurationPropertiesBinder {
|
||||
|
||||
private final Logger logger = LoggerFactory
|
||||
.getLogger(NacosBootConfigurationPropertiesBinder.class);
|
||||
private final ConfigurableApplicationContext applicationContext;
|
||||
|
||||
private ConfigurationBeanFactoryMetadata beanFactoryMetadata;
|
||||
private StandardEnvironment environment = new StandardEnvironment();
|
||||
private final StandardEnvironment environment = new StandardEnvironment();
|
||||
|
||||
public NacosBootConfigurationPropertiesBinder(
|
||||
ConfigurableApplicationContext applicationContext) {
|
||||
super(applicationContext);
|
||||
this.beanFactoryMetadata = applicationContext.getBean(
|
||||
ConfigurationBeanFactoryMetadata.BEAN_NAME,
|
||||
ConfigurationBeanFactoryMetadata.class);
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(Object bean, String beanName, String dataId, String groupId,
|
||||
String configType, NacosConfigurationProperties properties, String content,
|
||||
ConfigService configService) {
|
||||
String name = "nacos-bootstrap-" + beanName;
|
||||
NacosPropertySource propertySource = new NacosPropertySource(name, dataId,
|
||||
groupId, content, configType);
|
||||
environment.getPropertySources().addLast(propertySource);
|
||||
Binder binder = Binder.get(environment);
|
||||
ResolvableType type = getBeanType(bean, beanName);
|
||||
Bindable<?> target = Bindable.of(type).withExistingValue(bean);
|
||||
binder.bind(properties.prefix(), target);
|
||||
publishBoundEvent(bean, beanName, dataId, groupId, properties, content,
|
||||
configService);
|
||||
publishMetadataEvent(bean, beanName, dataId, groupId, properties);
|
||||
environment.getPropertySources().remove(name);
|
||||
synchronized (this) {
|
||||
String name = "nacos-bootstrap-" + beanName;
|
||||
NacosPropertySource propertySource = new NacosPropertySource(dataId, groupId, name, content, configType);
|
||||
environment.getPropertySources().addLast(propertySource);
|
||||
ObjectUtils.cleanMapOrCollectionField(bean);
|
||||
Binder binder = Binder.get(environment);
|
||||
ResolvableType type = getBeanType(bean, beanName);
|
||||
Bindable<?> target = Bindable.of(type).withExistingValue(bean);
|
||||
binder.bind(properties.prefix(), target);
|
||||
publishBoundEvent(bean, beanName, dataId, groupId, properties, content, configService);
|
||||
publishMetadataEvent(bean, beanName, dataId, groupId, properties);
|
||||
environment.getPropertySources().remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
private ResolvableType getBeanType(Object bean, String beanName) {
|
||||
Method factoryMethod = this.beanFactoryMetadata.findFactoryMethod(beanName);
|
||||
Method factoryMethod = findFactoryMethod(beanName);
|
||||
if (factoryMethod != null) {
|
||||
return ResolvableType.forMethodReturnType(factoryMethod);
|
||||
}
|
||||
return ResolvableType.forClass(bean.getClass());
|
||||
}
|
||||
|
||||
public Method findFactoryMethod(String beanName) {
|
||||
ConfigurableListableBeanFactory beanFactory = this.applicationContext.getBeanFactory();
|
||||
if (beanFactory.containsBeanDefinition(beanName)) {
|
||||
BeanDefinition beanDefinition = beanFactory.getMergedBeanDefinition(beanName);
|
||||
if (beanDefinition instanceof RootBeanDefinition) {
|
||||
return ((RootBeanDefinition) beanDefinition).getResolvedFactoryMethod();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
package com.alibaba.boot.nacos.config.logging;
|
||||
|
||||
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigPropertiesUtils;
|
||||
import com.alibaba.nacos.client.logging.NacosLogging;
|
||||
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
@ -43,12 +45,18 @@ public class NacosLoggingListener implements GenericApplicationListener {
|
|||
|
||||
@Override
|
||||
public boolean supportsSourceType(Class<?> aClass) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent applicationEvent) {
|
||||
NacosLogging.getInstance().loadConfiguration();
|
||||
//If the managed log is enabled, load your own log configuration after loading the user log configuration
|
||||
ApplicationEnvironmentPreparedEvent applicationEnvironmentPreparedEvent = (ApplicationEnvironmentPreparedEvent) applicationEvent;
|
||||
NacosConfigProperties nacosConfigProperties = NacosConfigPropertiesUtils.buildNacosConfigProperties(
|
||||
applicationEnvironmentPreparedEvent.getEnvironment());
|
||||
if(nacosConfigProperties.getBootstrap().isLogEnable()){
|
||||
NacosLogging.getInstance().loadConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@ package com.alibaba.boot.nacos.config.properties;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.alibaba.boot.nacos.config.NacosConfigConstants;
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
|
@ -60,7 +61,7 @@ public class NacosConfigProperties {
|
|||
|
||||
private String group = Constants.DEFAULT_GROUP;
|
||||
|
||||
private ConfigType type;
|
||||
private ConfigType type = ConfigType.PROPERTIES;
|
||||
|
||||
private String maxRetry;
|
||||
|
||||
|
@ -267,8 +268,8 @@ public class NacosConfigProperties {
|
|||
sb.append(", encode='").append(encode).append('\'');
|
||||
sb.append(", endpoint='").append(endpoint).append('\'');
|
||||
sb.append(", namespace='").append(namespace).append('\'');
|
||||
sb.append(", accessKey='").append(accessKey).append('\'');
|
||||
sb.append(", secretKey='").append(secretKey).append('\'');
|
||||
sb.append(", accessKey='").append(Objects.isNull(accessKey) ? null : "******").append('\'');
|
||||
sb.append(", secretKey='").append(Objects.isNull(secretKey) ? null : "******").append('\'');
|
||||
sb.append(", ramRoleName='").append(ramRoleName).append('\'');
|
||||
sb.append(", autoRefresh=").append(autoRefresh);
|
||||
sb.append(", dataId='").append(dataId).append('\'');
|
||||
|
@ -291,6 +292,8 @@ public class NacosConfigProperties {
|
|||
|
||||
private boolean logEnable;
|
||||
|
||||
private boolean snapshotEnable;
|
||||
|
||||
public boolean isEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
@ -307,10 +310,19 @@ public class NacosConfigProperties {
|
|||
this.logEnable = logEnable;
|
||||
}
|
||||
|
||||
public boolean isSnapshotEnable() {
|
||||
return snapshotEnable;
|
||||
}
|
||||
|
||||
public void setSnapshotEnable(boolean snapshotEnable) {
|
||||
this.snapshotEnable = snapshotEnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("Bootstrap{");
|
||||
sb.append("enable=").append(enable);
|
||||
sb.append(", snapshotEnable=").append(snapshotEnable);
|
||||
sb.append(", logEnable=").append(logEnable);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
|
@ -495,8 +507,8 @@ public class NacosConfigProperties {
|
|||
sb.append("serverAddr='").append(serverAddr).append('\'');
|
||||
sb.append(", endpoint='").append(endpoint).append('\'');
|
||||
sb.append(", namespace='").append(namespace).append('\'');
|
||||
sb.append(", accessKey='").append(accessKey).append('\'');
|
||||
sb.append(", secretKey='").append(secretKey).append('\'');
|
||||
sb.append(", accessKey='").append(Objects.isNull(accessKey) ? null : "******").append('\'');
|
||||
sb.append(", secretKey='").append(Objects.isNull(secretKey) ? null : "******").append('\'');
|
||||
sb.append(", ramRoleName='").append(ramRoleName).append('\'');
|
||||
sb.append(", dataId='").append(dataId).append('\'');
|
||||
sb.append(", dataIds='").append(dataIds).append('\'');
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.boot.nacos.config.support;
|
||||
|
||||
import com.alibaba.nacos.spring.core.env.AbstractNacosPropertySourceBuilder;
|
||||
import com.alibaba.nacos.spring.core.env.NacosPropertySource;
|
||||
import com.alibaba.nacos.spring.util.parse.DefaultYamlConfigParse;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.env.EnvironmentPostProcessor;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* yaml multi profiles.
|
||||
* <p>
|
||||
* read nacos propertysource:
|
||||
* <p>
|
||||
* 1. {@link AbstractNacosPropertySourceBuilder#doBuild(String, BeanDefinition, Map)}<br/>
|
||||
* 2. {@link NacosPropertySource#NacosPropertySource(String, String, String, String, String)}<br/>
|
||||
* 3. {@link com.alibaba.nacos.spring.util.NacosUtils#toProperties(String, String, String, String)}<br/>
|
||||
* 4. {@link com.alibaba.nacos.spring.util.ConfigParseUtils#toProperties(String, String, String, String)}<br/>
|
||||
*
|
||||
* @author <a href="mailto:yanglu_u@126.com">dbses</a>
|
||||
*/
|
||||
public class MultiProfilesYamlConfigParseSupport extends DefaultYamlConfigParse implements EnvironmentPostProcessor {
|
||||
|
||||
private static final String SPRING_PROFILES = "spring.profiles";
|
||||
|
||||
private static String[] profileArray = {};
|
||||
|
||||
@Override
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
String[] profiles = environment.getActiveProfiles();
|
||||
// fall back to default profiles
|
||||
if (profiles.length == 0) {
|
||||
profiles = environment.getDefaultProfiles();
|
||||
}
|
||||
// set once
|
||||
if (profileArray.length == 0) {
|
||||
profileArray = profiles;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> parse(String configText) {
|
||||
final AtomicReference<Map<String, Object>> result = new AtomicReference<>();
|
||||
process(map -> {
|
||||
// first block
|
||||
if (result.get() == null) {
|
||||
result.set(map);
|
||||
} else {
|
||||
setFromOtherBlock(result, map);
|
||||
}
|
||||
}, createYaml(), configText);
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private void setFromOtherBlock(AtomicReference<Map<String, Object>> result, Map<String, Object> map) {
|
||||
if (map.get(SPRING_PROFILES) == null) {
|
||||
result.get().putAll(map);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String profile : profileArray) {
|
||||
if (profile.equals(map.get(SPRING_PROFILES))) {
|
||||
result.get().putAll(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* for unit test
|
||||
*/
|
||||
static void setProfileArray(String[] profiles) {
|
||||
profileArray = profiles;
|
||||
}
|
||||
|
||||
}
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
import java.util.ListIterator;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
|
@ -42,32 +43,28 @@ import static com.alibaba.nacos.spring.util.NacosUtils.buildDefaultPropertySourc
|
|||
|
||||
/**
|
||||
* @author <a href="mailto:liaochunyhm@live.com">liaochuntao</a>
|
||||
* @author <a href="mailto:guofuyinan@gmail.com">guofuyinan</a>
|
||||
* @since 0.2.3
|
||||
*/
|
||||
public class NacosConfigLoader {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(NacosConfigLoader.class);
|
||||
|
||||
private final NacosConfigProperties nacosConfigProperties;
|
||||
private final ConfigurableEnvironment environment;
|
||||
private Function<Properties, ConfigService> builder;
|
||||
private List<DeferNacosPropertySource> nacosPropertySources = new LinkedList<>();
|
||||
private Properties globalProperties = new Properties();
|
||||
|
||||
public NacosConfigLoader(NacosConfigProperties nacosConfigProperties,
|
||||
ConfigurableEnvironment environment,
|
||||
Function<Properties, ConfigService> builder) {
|
||||
this.nacosConfigProperties = nacosConfigProperties;
|
||||
this.environment = environment;
|
||||
private final Function<Properties, ConfigService> builder;
|
||||
private final List<DeferNacosPropertySource> nacosPropertySources = new LinkedList<>();
|
||||
|
||||
public NacosConfigLoader(Function<Properties, ConfigService> builder) {
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
public void loadConfig() {
|
||||
Properties globalProperties = buildGlobalNacosProperties();
|
||||
public void loadConfig(ConfigurableEnvironment environment, NacosConfigProperties nacosConfigProperties) {
|
||||
globalProperties = buildGlobalNacosProperties(environment, nacosConfigProperties);
|
||||
MutablePropertySources mutablePropertySources = environment.getPropertySources();
|
||||
List<NacosPropertySource> sources = reqGlobalNacosConfig(globalProperties,
|
||||
nacosConfigProperties.getType());
|
||||
List<NacosPropertySource> sources = reqGlobalNacosConfig(environment, globalProperties, nacosConfigProperties);
|
||||
for (NacosConfigProperties.Config config : nacosConfigProperties.getExtConfig()) {
|
||||
List<NacosPropertySource> elements = reqSubNacosConfig(config,
|
||||
List<NacosPropertySource> elements = reqSubNacosConfig(environment, config,
|
||||
globalProperties, config.getType());
|
||||
sources.addAll(elements);
|
||||
}
|
||||
|
@ -83,7 +80,7 @@ public class NacosConfigLoader {
|
|||
}
|
||||
}
|
||||
|
||||
public Properties buildGlobalNacosProperties() {
|
||||
public Properties buildGlobalNacosProperties(ConfigurableEnvironment environment, NacosConfigProperties nacosConfigProperties) {
|
||||
return NacosPropertiesBuilder.buildNacosProperties(environment,
|
||||
nacosConfigProperties.getServerAddr(),
|
||||
nacosConfigProperties.getNamespace(), nacosConfigProperties.getEndpoint(),
|
||||
|
@ -93,30 +90,35 @@ public class NacosConfigLoader {
|
|||
nacosConfigProperties.getConfigLongPollTimeout(),
|
||||
nacosConfigProperties.getConfigRetryTime(),
|
||||
nacosConfigProperties.getMaxRetry(),
|
||||
nacosConfigProperties.getContextPath(),
|
||||
nacosConfigProperties.isEnableRemoteSyncConfig(),
|
||||
nacosConfigProperties.getUsername(), nacosConfigProperties.getPassword());
|
||||
}
|
||||
|
||||
private Properties buildSubNacosProperties(Properties globalProperties,
|
||||
private Properties buildSubNacosProperties(ConfigurableEnvironment environment, Properties globalProperties,
|
||||
NacosConfigProperties.Config config) {
|
||||
Properties sub = NacosPropertiesBuilder.buildNacosProperties(environment,
|
||||
config.getServerAddr(), config.getNamespace(), config.getEndpoint(),
|
||||
config.getSecretKey(), config.getAccessKey(), config.getRamRoleName(),
|
||||
config.getConfigLongPollTimeout(), config.getConfigRetryTime(),
|
||||
config.getMaxRetry(), config.isEnableRemoteSyncConfig(),
|
||||
config.getMaxRetry(),null, config.isEnableRemoteSyncConfig(),
|
||||
config.getUsername(), config.getPassword());
|
||||
NacosPropertiesBuilder.merge(sub, globalProperties);
|
||||
return sub;
|
||||
}
|
||||
|
||||
private List<NacosPropertySource> reqGlobalNacosConfig(Properties globalProperties,
|
||||
ConfigType type) {
|
||||
private List<NacosPropertySource> reqGlobalNacosConfig(ConfigurableEnvironment environment, Properties globalProperties,
|
||||
NacosConfigProperties nacosConfigProperties) {
|
||||
List<String> dataIds = new ArrayList<>();
|
||||
// Loads all data-id information into the list in the list
|
||||
if (StringUtils.isEmpty(nacosConfigProperties.getDataId())) {
|
||||
if (!StringUtils.hasLength(nacosConfigProperties.getDataId())) {
|
||||
final String ids = environment
|
||||
.resolvePlaceholders(nacosConfigProperties.getDataIds());
|
||||
dataIds.addAll(Arrays.asList(ids.split(",")));
|
||||
if(StringUtils.hasText(ids)){
|
||||
dataIds.addAll(Arrays.stream(ids.split(","))
|
||||
.filter(StringUtils::hasText)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
dataIds.add(nacosConfigProperties.getDataId());
|
||||
|
@ -124,17 +126,17 @@ public class NacosConfigLoader {
|
|||
final String groupName = environment
|
||||
.resolvePlaceholders(nacosConfigProperties.getGroup());
|
||||
final boolean isAutoRefresh = nacosConfigProperties.isAutoRefresh();
|
||||
return new ArrayList<>(Arrays.asList(reqNacosConfig(globalProperties,
|
||||
dataIds.toArray(new String[0]), groupName, type, isAutoRefresh)));
|
||||
return new ArrayList<>(Arrays.asList(reqNacosConfig(environment, globalProperties,
|
||||
dataIds.toArray(new String[0]), groupName, nacosConfigProperties.getType(), isAutoRefresh)));
|
||||
}
|
||||
|
||||
private List<NacosPropertySource> reqSubNacosConfig(
|
||||
private List<NacosPropertySource> reqSubNacosConfig(ConfigurableEnvironment environment,
|
||||
NacosConfigProperties.Config config, Properties globalProperties,
|
||||
ConfigType type) {
|
||||
Properties subConfigProperties = buildSubNacosProperties(globalProperties,
|
||||
Properties subConfigProperties = buildSubNacosProperties(environment, globalProperties,
|
||||
config);
|
||||
ArrayList<String> dataIds = new ArrayList<>();
|
||||
if (StringUtils.isEmpty(config.getDataId())) {
|
||||
if (!StringUtils.hasLength(config.getDataId())) {
|
||||
final String ids = environment.resolvePlaceholders(config.getDataIds());
|
||||
dataIds.addAll(Arrays.asList(ids.split(",")));
|
||||
}
|
||||
|
@ -143,15 +145,15 @@ public class NacosConfigLoader {
|
|||
}
|
||||
final String groupName = environment.resolvePlaceholders(config.getGroup());
|
||||
final boolean isAutoRefresh = config.isAutoRefresh();
|
||||
return new ArrayList<>(Arrays.asList(reqNacosConfig(subConfigProperties,
|
||||
return new ArrayList<>(Arrays.asList(reqNacosConfig(environment, subConfigProperties,
|
||||
dataIds.toArray(new String[0]), groupName, type, isAutoRefresh)));
|
||||
}
|
||||
|
||||
private NacosPropertySource[] reqNacosConfig(Properties configProperties,
|
||||
private NacosPropertySource[] reqNacosConfig(ConfigurableEnvironment environment, Properties configProperties,
|
||||
String[] dataIds, String groupId, ConfigType type, boolean isAutoRefresh) {
|
||||
final NacosPropertySource[] propertySources = new NacosPropertySource[dataIds.length];
|
||||
for (int i = 0; i < dataIds.length; i++) {
|
||||
if (StringUtils.isEmpty(dataIds[i])) {
|
||||
if (!StringUtils.hasLength(dataIds[i])) {
|
||||
continue;
|
||||
}
|
||||
// Remove excess Spaces
|
||||
|
@ -194,6 +196,11 @@ public class NacosConfigLoader {
|
|||
return nacosPropertySources;
|
||||
}
|
||||
|
||||
|
||||
public Properties getGlobalProperties() {
|
||||
return globalProperties;
|
||||
}
|
||||
|
||||
// Delay Nacos configuration data source object, used for log level of loading time,
|
||||
// the cache configuration, wait for after the completion of the Spring Context
|
||||
// created in the release
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.boot.nacos.config.util;
|
||||
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* NacosConfigLoaderFactory.
|
||||
* @author hujun
|
||||
*/
|
||||
public class NacosConfigLoaderFactory {
|
||||
|
||||
private static volatile NacosConfigLoader nacosConfigLoader;
|
||||
|
||||
public static NacosConfigLoader getSingleton(Function<Properties, ConfigService> builder) {
|
||||
if (nacosConfigLoader == null) {
|
||||
synchronized (NacosConfigLoaderFactory.class) {
|
||||
if (nacosConfigLoader == null) {
|
||||
nacosConfigLoader = new NacosConfigLoader(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
return nacosConfigLoader;
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ package com.alibaba.boot.nacos.config.util;
|
|||
|
||||
import com.alibaba.boot.nacos.config.NacosConfigConstants;
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -26,6 +27,9 @@ import org.springframework.boot.context.properties.bind.Binder;
|
|||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Springboot used to own property binding configured binding
|
||||
*
|
||||
|
|
|
@ -34,57 +34,32 @@ public class NacosPropertiesBuilder {
|
|||
public static Properties buildNacosProperties(Environment environment,
|
||||
String serverAddr, String namespaceId, String endpoint, String secretKey,
|
||||
String accessKey, String ramRoleName, String configLongPollTimeout,
|
||||
String configRetryTimeout, String maxRetry, boolean enableRemoteSyncConfig,
|
||||
String configRetryTimeout, String maxRetry,String contextPath, boolean enableRemoteSyncConfig,
|
||||
String username, String password) {
|
||||
Properties properties = new Properties();
|
||||
if (StringUtils.isNotEmpty(serverAddr)) {
|
||||
properties.put(PropertyKeyConst.SERVER_ADDR,
|
||||
environment.resolvePlaceholders(serverAddr));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(namespaceId)) {
|
||||
properties.put(PropertyKeyConst.NAMESPACE,
|
||||
environment.resolvePlaceholders(namespaceId));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(endpoint)) {
|
||||
properties.put(PropertyKeyConst.ENDPOINT,
|
||||
environment.resolvePlaceholders(endpoint));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(secretKey)) {
|
||||
properties.put(PropertyKeyConst.SECRET_KEY,
|
||||
environment.resolvePlaceholders(secretKey));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(accessKey)) {
|
||||
properties.put(PropertyKeyConst.ACCESS_KEY,
|
||||
environment.resolvePlaceholders(accessKey));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(ramRoleName)) {
|
||||
properties.put(PropertyKeyConst.RAM_ROLE_NAME,
|
||||
environment.resolvePlaceholders(ramRoleName));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(configLongPollTimeout)) {
|
||||
properties.put(PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT,
|
||||
environment.resolvePlaceholders(configLongPollTimeout));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(configRetryTimeout)) {
|
||||
properties.put(PropertyKeyConst.CONFIG_RETRY_TIME,
|
||||
environment.resolvePlaceholders(configRetryTimeout));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(maxRetry)) {
|
||||
properties.put(PropertyKeyConst.MAX_RETRY,
|
||||
environment.resolvePlaceholders(maxRetry));
|
||||
}
|
||||
if (StringUtils.isNotBlank(username)) {
|
||||
properties.put(PropertyKeyConst.USERNAME,
|
||||
environment.resolvePlaceholders(username));
|
||||
}
|
||||
if (StringUtils.isNotBlank(password)) {
|
||||
properties.put(PropertyKeyConst.PASSWORD,
|
||||
environment.resolvePlaceholders(password));
|
||||
}
|
||||
processPropertiesData(properties,environment,serverAddr,PropertyKeyConst.SERVER_ADDR);
|
||||
processPropertiesData(properties,environment,namespaceId,PropertyKeyConst.NAMESPACE);
|
||||
processPropertiesData(properties,environment,endpoint,PropertyKeyConst.ENDPOINT);
|
||||
processPropertiesData(properties,environment,secretKey,PropertyKeyConst.SECRET_KEY);
|
||||
processPropertiesData(properties,environment,accessKey,PropertyKeyConst.ACCESS_KEY);
|
||||
processPropertiesData(properties,environment,ramRoleName,PropertyKeyConst.RAM_ROLE_NAME);
|
||||
processPropertiesData(properties,environment,configLongPollTimeout,PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT);
|
||||
processPropertiesData(properties,environment,configRetryTimeout,PropertyKeyConst.CONFIG_RETRY_TIME);
|
||||
processPropertiesData(properties,environment,contextPath,PropertyKeyConst.CONTEXT_PATH);
|
||||
processPropertiesData(properties,environment,maxRetry,PropertyKeyConst.MAX_RETRY);
|
||||
processPropertiesData(properties,environment,username,PropertyKeyConst.USERNAME);
|
||||
processPropertiesData(properties,environment,password,PropertyKeyConst.PASSWORD);
|
||||
|
||||
properties.put(PropertyKeyConst.ENABLE_REMOTE_SYNC_CONFIG,
|
||||
String.valueOf(enableRemoteSyncConfig));
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static void processPropertiesData(Properties properties,Environment environment,String keyword,String key) {
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
properties.put(key ,environment.resolvePlaceholders(keyword));
|
||||
}
|
||||
}
|
||||
|
||||
public static void merge(Properties targetProperties, Properties sourceProperties) {
|
||||
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.config.util.log;
|
||||
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoader;
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.listener.AbstractListener;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.client.config.utils.ConcurrentDiskUtil;
|
||||
import com.alibaba.nacos.client.config.utils.JvmUtil;
|
||||
import com.alibaba.nacos.client.logging.NacosLogging;
|
||||
import com.alibaba.nacos.client.utils.LogUtils;
|
||||
import com.alibaba.nacos.common.utils.IoUtils;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.alibaba.nacos.spring.util.NacosUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.boot.context.logging.LoggingApplicationListener;
|
||||
import org.springframework.boot.logging.LoggingInitializationContext;
|
||||
import org.springframework.boot.logging.LoggingSystem;
|
||||
import org.springframework.boot.logging.LoggingSystemFactory;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Start:
|
||||
* Step1: get the log XML configuration from the configuration center
|
||||
* Step2: modify the springboot log configuration path
|
||||
* Modifying log configuration during operation:
|
||||
* Clean up the configuration through LoggingSystem and reload the configuration.
|
||||
*
|
||||
* @author <a href="mailto:hujun3@xiaomi.com">hujun</a>
|
||||
*/
|
||||
public class LogAutoFreshProcess {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.logger(LogAutoFreshProcess.class);
|
||||
|
||||
private final NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
private final ConfigurableEnvironment environment;
|
||||
|
||||
private final NacosConfigLoader nacosConfigLoader;
|
||||
|
||||
private final Function<Properties, ConfigService> builder;
|
||||
|
||||
private static final List<String> LOG_DATA_ID = new ArrayList<>();
|
||||
|
||||
private static final String LOG_CACHE_BASE = System.getProperty("JM.SNAPSHOT.PATH", System.getProperty("user.home")) + File.separator + "nacos"
|
||||
+ File.separator + "logConfig";
|
||||
|
||||
static {
|
||||
LOG_DATA_ID.add("logback.xml");
|
||||
LOG_DATA_ID.add("log4j2.xml");
|
||||
}
|
||||
|
||||
public static LogAutoFreshProcess build(ConfigurableEnvironment environment, NacosConfigProperties nacosConfigProperties, NacosConfigLoader nacosConfigLoader, Function<Properties, ConfigService> builder) {
|
||||
return new LogAutoFreshProcess(environment, nacosConfigProperties, nacosConfigLoader, builder);
|
||||
}
|
||||
|
||||
private LogAutoFreshProcess(ConfigurableEnvironment environment, NacosConfigProperties nacosConfigProperties, NacosConfigLoader nacosConfigLoader, Function<Properties, ConfigService> builder) {
|
||||
this.nacosConfigProperties = nacosConfigProperties;
|
||||
this.environment = environment;
|
||||
this.nacosConfigLoader = nacosConfigLoader;
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
public void process() {
|
||||
final String groupName = environment
|
||||
.resolvePlaceholders(nacosConfigProperties.getGroup());
|
||||
ConfigService configService = builder.apply(nacosConfigLoader.getGlobalProperties());
|
||||
for (String dataId : LOG_DATA_ID) {
|
||||
String content = NacosUtils.getContent(configService, dataId, groupName);
|
||||
if (StringUtils.isNotBlank(content)) {
|
||||
writeLogFile(content, dataId);
|
||||
System.setProperty(LoggingApplicationListener.CONFIG_PROPERTY, LOG_CACHE_BASE + File.separator + dataId);
|
||||
registerListener(configService, dataId, groupName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerListener(ConfigService configService, String dataId, String groupName) {
|
||||
try {
|
||||
configService.addListener(dataId, groupName, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
if (StringUtils.isNotBlank(configInfo)) {
|
||||
writeLogFile(configInfo, dataId);
|
||||
reloadConfig(LOG_CACHE_BASE + File.separator + dataId);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (NacosException e) {
|
||||
throw new RuntimeException("ConfigService can't add Listener with dataId : " + dataId, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeLogFile(String content, String dataId) {
|
||||
File file = new File(LOG_CACHE_BASE, dataId);
|
||||
File parentFile = file.getParentFile();
|
||||
if (!parentFile.exists()) {
|
||||
boolean isMdOk = parentFile.mkdirs();
|
||||
if (!isMdOk) {
|
||||
LOGGER.error("save log cache error");
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (JvmUtil.isMultiInstance()) {
|
||||
ConcurrentDiskUtil.writeFileContent(file, content, Constants.ENCODE);
|
||||
} else {
|
||||
IoUtils.writeStringToFile(file, content, Constants.ENCODE);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("write log file fail");
|
||||
}
|
||||
}
|
||||
|
||||
private void reloadConfig(String logPath) {
|
||||
LoggingSystem loggingSystem = LoggingSystemFactory.fromSpringFactories()
|
||||
.getLoggingSystem(this.getClass().getClassLoader());
|
||||
loggingSystem.cleanUp();
|
||||
loggingSystem.initialize(new LoggingInitializationContext(environment),
|
||||
logPath, null);
|
||||
NacosLogging.getInstance().loadConfiguration();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"resources": {
|
||||
"includes": [
|
||||
{
|
||||
"pattern": "\\QMETA-INF/services/com.alibaba.nacos.spring.util.ConfigParse\\E"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.alibaba.boot.nacos.config.support.MultiProfilesYamlConfigParseSupport
|
|
@ -3,6 +3,7 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|||
#org.springframework.context.ApplicationContextInitializer=\
|
||||
# com.alibaba.boot.nacos.config.autoconfigure.NacosConfigApplicationContextInitializer
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=\
|
||||
com.alibaba.boot.nacos.config.autoconfigure.NacosConfigEnvironmentProcessor
|
||||
com.alibaba.boot.nacos.config.autoconfigure.NacosConfigEnvironmentProcessor,\
|
||||
com.alibaba.boot.nacos.config.support.MultiProfilesYamlConfigParseSupport
|
||||
org.springframework.context.ApplicationListener=\
|
||||
com.alibaba.boot.nacos.config.logging.NacosLoggingListener
|
|
@ -0,0 +1,4 @@
|
|||
com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration
|
||||
com.alibaba.boot.nacos.config.autoconfigure.NacosConfigEnvironmentProcessor
|
||||
com.alibaba.boot.nacos.config.support.MultiProfilesYamlConfigParseSupport
|
||||
com.alibaba.boot.nacos.config.logging.NacosLoggingListener
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosBootConfigException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* {@link NacosBootConfigException} Test
|
||||
* @ClassName: NacosBootConfigExceptionTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 15:56
|
||||
*/
|
||||
public class NacosBootConfigExceptionTest {
|
||||
|
||||
@Test
|
||||
public void getCons() {
|
||||
try {
|
||||
testMethod("spring boot");
|
||||
}catch (Exception e) {
|
||||
Assert.assertTrue(e instanceof NacosBootConfigException);
|
||||
}
|
||||
}
|
||||
|
||||
private void testMethod(String str) {
|
||||
if (str.startsWith("spring")) {
|
||||
throw new NacosBootConfigException(new Throwable());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigApplicationContextInitializer;
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigBootBeanDefinitionRegistrar;
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigEnvironmentProcessor;
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoader;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoaderFactory;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigPropertiesUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* {@link NacosConfigApplicationContextInitializer} Test
|
||||
* @ClassName: NacosConfigApplicationContextInitializerTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 15:25
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestPropertySource(properties = { "nacos.config.server-addr=localhost" })
|
||||
@SpringBootTest(classes = { NacosConfigAutoConfiguration.class })
|
||||
public class NacosConfigApplicationContextInitializerTest {
|
||||
|
||||
private NacosConfigApplicationContextInitializer nacosConfigApplicationContextInitializer;
|
||||
|
||||
@Autowired
|
||||
private ConfigurableEnvironment environment;
|
||||
|
||||
@Autowired
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
@Autowired
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
public void testNacosConfigApplicationContextInitializer() {
|
||||
nacosConfigApplicationContextInitializer = new NacosConfigApplicationContextInitializer(new NacosConfigEnvironmentProcessor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize(){
|
||||
try {
|
||||
nacosConfigProperties = NacosConfigPropertiesUtils
|
||||
.buildNacosConfigProperties(environment);
|
||||
Assert.assertNotNull(nacosConfigProperties);
|
||||
NacosConfigLoader singleton = NacosConfigLoaderFactory.getSingleton(null);
|
||||
Assert.assertNotNull(singleton);
|
||||
nacosConfigApplicationContextInitializer.initialize(context);
|
||||
} catch (Exception e) {
|
||||
Assert.assertNotNull(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ package com.alibaba.boot.nacos.autoconfigure;
|
|||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.binder.NacosBootConfigurationPropertiesBinder;
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
|
@ -84,4 +85,8 @@ public class NacosConfigAutoConfigurationTest {
|
|||
properties.getProperty(PropertyKeyConst.SERVER_ADDR));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNacosConfigBootBeanDefinitionRegistrar() {
|
||||
Assert.assertNotNull(applicationContext.getBean(NacosBootConfigurationPropertiesBinder.BEAN_NAME));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigBootBeanDefinitionRegistrar;
|
||||
import com.alibaba.boot.nacos.config.binder.NacosBootConfigurationPropertiesBinder;
|
||||
import com.alibaba.nacos.client.utils.LogUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* {@link NacosConfigBootBeanDefinitionRegistrar} Test
|
||||
* @ClassName: NacosConfigBootBeanDefinitionRegistrarTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 15:38
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestPropertySource(properties = { "nacos.config.server-addr=localhost" })
|
||||
@SpringBootTest(classes = { NacosConfigAutoConfiguration.class })
|
||||
public class NacosConfigBootBeanDefinitionRegistrarTest {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.logger(NacosConfigBootBeanDefinitionRegistrarTest.class);
|
||||
|
||||
private NacosConfigBootBeanDefinitionRegistrar nacosConfigBootBeanDefinitionRegistrar;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
nacosConfigBootBeanDefinitionRegistrar = new NacosConfigBootBeanDefinitionRegistrar();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setBeanFactory(){
|
||||
try {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition("beanName");
|
||||
Assert.assertNotNull(builder);
|
||||
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
nacosConfigBootBeanDefinitionRegistrar.setBeanFactory(beanFactory);
|
||||
Assert.assertNotNull(beanFactory.getBeanDefinition(NacosBootConfigurationPropertiesBinder.BEAN_NAME));
|
||||
nacosConfigBootBeanDefinitionRegistrar.setBeanFactory(beanFactory);
|
||||
}catch (Exception e) {
|
||||
LOGGER.error("error info: {}",e.toString());
|
||||
Assert.assertNull(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigEnvironmentProcessor;
|
||||
import com.alibaba.boot.nacos.config.binder.NacosBootConfigurationPropertiesBinder;
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigPropertiesUtils;
|
||||
import com.alibaba.nacos.client.config.NacosConfigService;
|
||||
import com.alibaba.nacos.client.utils.LogUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* {@link NacosBootConfigurationPropertiesBinder} Test
|
||||
* @ClassName: NacosConfigEnvironmentProcessorTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 15:43
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestPropertySource(properties = { "nacos.config.server-addr=localhost" })
|
||||
@SpringBootTest(classes = { NacosConfigAutoConfiguration.class })
|
||||
public class NacosConfigEnvironmentProcessorTest {
|
||||
|
||||
private NacosConfigEnvironmentProcessor nacosConfigEnvironmentProcessor;
|
||||
|
||||
@Autowired
|
||||
private ConfigurableEnvironment environment;
|
||||
|
||||
private static final Logger LOGGER = LogUtils.logger(NacosConfigEnvironmentProcessorTest.class);
|
||||
|
||||
@Mock
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
nacosConfigEnvironmentProcessor = new NacosConfigEnvironmentProcessor();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void postProcessEnvironment() {
|
||||
try {
|
||||
NacosConfigProperties nacosConfigProperties1 = NacosConfigPropertiesUtils.buildNacosConfigProperties(
|
||||
environment);
|
||||
Assert.assertFalse(nacosConfigProperties1.isEnableRemoteSyncConfig());
|
||||
nacosConfigEnvironmentProcessor.postProcessEnvironment(environment, new SpringApplication());
|
||||
}catch (Exception e) {
|
||||
LOGGER.error("error info :{} ",e);
|
||||
Assert.assertNull(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOrder() {
|
||||
int order = nacosConfigEnvironmentProcessor.getOrder();
|
||||
Assert.assertNotNull(order);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.binder;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.binder.NacosBootConfigurationPropertiesBinder;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.annotation.NacosConfigurationProperties;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.spring.context.event.config.EventPublishingConfigService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* {@link NacosBootConfigurationPropertiesBinder} Test
|
||||
* @ClassName: NacosBootConfigurationPropertiesBinderTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 16:00
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestPropertySource(properties = { "nacos.config.server-addr=localhost" })
|
||||
@SpringBootTest(classes = { NacosConfigAutoConfiguration.class })
|
||||
public class NacosBootConfigurationPropertiesBinderTest {
|
||||
|
||||
private Binder binder;
|
||||
|
||||
@Autowired
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
binder = new Binder(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findFactoryMethod(){
|
||||
Method beanName = binder.findFactoryMethod(NacosBootConfigurationPropertiesBinder.BEAN_NAME);
|
||||
Assert.assertNull(beanName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoBind() {
|
||||
People people = new People();
|
||||
binder.doBind(people, "people", "people", "people", "properties",
|
||||
People.class.getAnnotation(NacosConfigurationProperties.class), "people.name=SuperZ1999\npeople.age=24",
|
||||
new EventPublishingConfigService(null, null, context, null));
|
||||
Assert.assertEquals(people.getName(), "SuperZ1999");
|
||||
Assert.assertEquals(people.getAge(), 24);
|
||||
}
|
||||
|
||||
static class Binder extends NacosBootConfigurationPropertiesBinder {
|
||||
|
||||
public Binder(ConfigurableApplicationContext applicationContext) {
|
||||
super(applicationContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(Object bean, String beanName, String dataId, String groupId, String configType, NacosConfigurationProperties properties, String content, ConfigService configService) {
|
||||
super.doBind(bean, beanName, dataId, groupId, configType, properties, content, configService);
|
||||
}
|
||||
}
|
||||
|
||||
@NacosConfigurationProperties(prefix = "people", dataId = "people", groupId = "people")
|
||||
static class People {
|
||||
private String name;
|
||||
private int age;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.boot.nacos.config.support;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.nacos.spring.util.ConfigParseUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* {@link MultiProfilesYamlConfigParseSupport} Test
|
||||
*
|
||||
* @author <a href="mailto:yanglu_u@126.com">dbses</a>
|
||||
*/
|
||||
public class MultiProfilesYamlConfigParseSupportTest {
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ActiveProfiles({"alpha"})
|
||||
@SpringBootTest(classes = {NacosConfigAutoConfiguration.class})
|
||||
public static class OneProfiles {
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// because MultiProfilesYamlConfigParseSupport # postProcessEnvironment() run once,
|
||||
// so it should set profilesArray before test
|
||||
MultiProfilesYamlConfigParseSupport.setProfileArray(environment.getActiveProfiles());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneProfiles_normal() {
|
||||
String content = "test1:\n" +
|
||||
" config: 2\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"spring:\n" +
|
||||
" profiles: alpha\n" +
|
||||
"test1:\n" +
|
||||
" config: alpha\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"spring:\n" +
|
||||
" profiles: beta\n" +
|
||||
"test1:\n" +
|
||||
" config: beta";
|
||||
Assert.assertEquals(environment.getActiveProfiles()[0], "alpha");
|
||||
Object result = ConfigParseUtils.toProperties("test.yaml", "test", content, "yaml")
|
||||
.get("test1.config");
|
||||
Assert.assertEquals("alpha", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneProfiles_when_content_profiles_isnull() {
|
||||
String content = "test1:\n" +
|
||||
" config: 2\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"test1:\n" +
|
||||
" config: alpha\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"test1:\n" +
|
||||
" config: beta";
|
||||
Object result = ConfigParseUtils.toProperties("test.yaml", "test", content, "yaml")
|
||||
.get("test1.config");
|
||||
Assert.assertEquals("beta", result);
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ActiveProfiles({"alpha", "beta"})
|
||||
@SpringBootTest(classes = {NacosConfigAutoConfiguration.class})
|
||||
public static class TwoProfiles {
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MultiProfilesYamlConfigParseSupport.setProfileArray(environment.getActiveProfiles());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void twoProfiles_normal() {
|
||||
String content = "test1:\n" +
|
||||
" config: 2\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"spring:\n" +
|
||||
" profiles: alpha\n" +
|
||||
"test1:\n" +
|
||||
" config: alpha\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"spring:\n" +
|
||||
" profiles: beta\n" +
|
||||
"test1:\n" +
|
||||
" config: beta";
|
||||
Assert.assertEquals(environment.getActiveProfiles()[0], "alpha");
|
||||
Assert.assertEquals(environment.getActiveProfiles()[1], "beta");
|
||||
Object result = ConfigParseUtils.toProperties("test.yaml", "test", content, "yaml")
|
||||
.get("test1.config");
|
||||
Assert.assertEquals("beta", result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = {NacosConfigAutoConfiguration.class})
|
||||
public static class NoProfiles {
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@Test
|
||||
public void noProfiles_normal() {
|
||||
String content = "test1:\n" +
|
||||
" config: 2\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"spring:\n" +
|
||||
" profiles: default\n" +
|
||||
"test1:\n" +
|
||||
" config: default\n" +
|
||||
"\n" +
|
||||
"---\n" +
|
||||
"spring:\n" +
|
||||
" profiles: beta\n" +
|
||||
"test1:\n" +
|
||||
" config: beta";
|
||||
Assert.assertEquals(environment.getActiveProfiles().length, 0);
|
||||
Object result = ConfigParseUtils.toProperties("test.yaml", "test", content, "yaml")
|
||||
.get("test1.config");
|
||||
Assert.assertEquals("default", result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.logging;
|
||||
|
||||
import com.alibaba.boot.nacos.config.logging.NacosLoggingListener;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* {@link NacosLoggingListener} Test
|
||||
* @ClassName: AttributeExtractTaskTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 15:08
|
||||
*/
|
||||
public class NacosLoggingListenerTest {
|
||||
private NacosLoggingListener nacosLoggingListener;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
nacosLoggingListener = new NacosLoggingListener();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supportsEventType() {
|
||||
boolean result = nacosLoggingListener.supportsEventType(ResolvableType.forType(new Type() {
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return Type.super.getTypeName();
|
||||
}
|
||||
}));
|
||||
Assert.assertEquals(result, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOrder() {
|
||||
int order = nacosLoggingListener.getOrder();
|
||||
Assert.assertNotNull(order);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.util;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.util.AttributeExtractTask;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
import org.springframework.core.env.PropertySources;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* {@link AttributeExtractTask} Test
|
||||
* @ClassName: AttributeExtractTaskTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 15:08
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestPropertySource(properties = { "nacos.config.server-addr=localhost" })
|
||||
@SpringBootTest(classes = { NacosConfigAutoConfiguration.class })
|
||||
public class AttributeExtractTaskTest {
|
||||
|
||||
private AttributeExtractTask attributeExtractTask;
|
||||
|
||||
@Autowired
|
||||
private ConfigurableEnvironment environment ;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
environment.setDefaultProfiles("prefix01");
|
||||
attributeExtractTask = new AttributeExtractTask("nacos.config",environment);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void call() throws Exception{
|
||||
Map<String, String> map = attributeExtractTask.call();
|
||||
Assert.assertEquals(map.get("nacos.config.server-addr"), "localhost");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.util;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoader;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoaderFactory;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.ConfigType;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.client.config.NacosConfigService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @ClassName: NacosConfigLoaderFactoryTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 16:42
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestPropertySource(properties = { "nacos.config.server-addr=localhost" })
|
||||
@SpringBootTest(classes = { NacosConfigAutoConfiguration.class })
|
||||
public class NacosConfigLoaderFactoryTest {
|
||||
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
private Properties globalProperties;
|
||||
|
||||
private Function<Properties, ConfigService> builder;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
nacosConfigProperties = new NacosConfigProperties();
|
||||
nacosConfigProperties.setServerAddr("localhost");
|
||||
nacosConfigProperties.setUsername("nacos");
|
||||
nacosConfigProperties.setPassword("nacos");
|
||||
nacosConfigProperties.setMaxRetry("4");
|
||||
nacosConfigProperties.setType(ConfigType.TEXT);
|
||||
nacosConfigProperties.setDataId("xiaomi");
|
||||
nacosConfigProperties.setGroup("group01");
|
||||
nacosConfigProperties.setAutoRefresh(true);
|
||||
nacosConfigProperties.setEndpoint("localhost");
|
||||
globalProperties = new Properties();
|
||||
globalProperties.setProperty("maxRetry","3");
|
||||
globalProperties.setProperty("content","key=01");
|
||||
globalProperties.setProperty("endpoint","localhost");
|
||||
builder = properties -> {
|
||||
try {
|
||||
return new NacosConfigService(globalProperties);
|
||||
} catch (NacosException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSingleton() {
|
||||
NacosConfigLoader singleton = NacosConfigLoaderFactory.getSingleton(builder);
|
||||
NacosConfigLoader singleton2 = NacosConfigLoaderFactory.getSingleton(builder);
|
||||
// Verify that it is the same object
|
||||
Assert.assertEquals(singleton2, singleton);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.util;
|
||||
|
||||
import com.alibaba.boot.nacos.autoconfigure.NacosConfigEnvironmentProcessorTest;
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigLoader;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.ConfigType;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.client.config.NacosConfigService;
|
||||
import com.alibaba.nacos.client.utils.LogUtils;
|
||||
import com.alibaba.nacos.spring.core.env.NacosPropertySourcePostProcessor;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @ClassName: NacosConfigLoaderTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 16:12
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestPropertySource(properties = { "nacos.config.server-addr=localhost" })
|
||||
@SpringBootTest(classes = { NacosConfigAutoConfiguration.class })
|
||||
public class NacosConfigLoaderTest {
|
||||
|
||||
private NacosConfigLoader nacosConfigLoader;
|
||||
|
||||
private NacosConfigProperties nacosConfigProperties;
|
||||
|
||||
private Properties globalProperties;
|
||||
|
||||
@Autowired
|
||||
private ConfigurableEnvironment environment;
|
||||
|
||||
private Function<Properties, ConfigService> builder;
|
||||
|
||||
private List<NacosConfigLoader.DeferNacosPropertySource> nacosPropertySources;
|
||||
|
||||
private static final Logger LOGGER = LogUtils.logger(NacosConfigEnvironmentProcessorTest.class);
|
||||
|
||||
private NacosPropertySourcePostProcessor nacosPropertySourcePostProcessor;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
nacosConfigProperties = new NacosConfigProperties();
|
||||
nacosConfigProperties.setServerAddr("localhost");
|
||||
nacosConfigProperties.setUsername("nacos");
|
||||
nacosConfigProperties.setPassword("nacos");
|
||||
nacosConfigProperties.setMaxRetry("4");
|
||||
nacosConfigProperties.setType(ConfigType.TEXT);
|
||||
nacosConfigProperties.setDataId("xiaomi");
|
||||
nacosConfigProperties.setGroup("group01");
|
||||
nacosConfigProperties.setAutoRefresh(true);
|
||||
nacosConfigProperties.setEndpoint("localhost");
|
||||
globalProperties = new Properties();
|
||||
globalProperties.setProperty("maxRetry","3");
|
||||
globalProperties.setProperty("content","key=01");
|
||||
globalProperties.setProperty("endpoint","localhost");
|
||||
builder = properties -> {
|
||||
try {
|
||||
return new NacosConfigService(globalProperties);
|
||||
} catch (NacosException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
nacosPropertySources = new LinkedList<>();
|
||||
nacosConfigLoader = new NacosConfigLoader(builder);
|
||||
nacosPropertySourcePostProcessor = new NacosPropertySourcePostProcessor();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildGlobalNacosProperties() {
|
||||
Properties properties = nacosConfigLoader.buildGlobalNacosProperties(environment, nacosConfigProperties);
|
||||
LOGGER.info("buildGlobalNacosProperties properties : {}", properties);
|
||||
Assert.assertNotNull(properties);
|
||||
Assert.assertEquals(properties.size(), 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addListenerIfAutoRefreshed() {
|
||||
nacosConfigLoader.addListenerIfAutoRefreshed();
|
||||
List<NacosConfigLoader.DeferNacosPropertySource> propertySources = nacosConfigLoader.getNacosPropertySources();
|
||||
Assert.assertEquals(propertySources.size(), 0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.util;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.properties.NacosConfigProperties;
|
||||
import com.alibaba.boot.nacos.config.util.NacosConfigPropertiesUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* {@link NacosConfigPropertiesUtils} Test
|
||||
* @ClassName: NacosConfigPropertiesUtilsTest
|
||||
* @Author: SuperZ1999
|
||||
* @Date: 2023/9/28
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = { NacosConfigAutoConfiguration.class })
|
||||
@TestPropertySource(properties = {
|
||||
"nacos.config.server-addr=8.8.8.8",
|
||||
"nacos.config.password=123456"
|
||||
})
|
||||
public class NacosConfigPropertiesUtilsTest {
|
||||
@Autowired
|
||||
private ConfigurableEnvironment environment;
|
||||
|
||||
@Test
|
||||
public void testBuildNacosConfigProperties() {
|
||||
NacosConfigProperties properties = NacosConfigPropertiesUtils.buildNacosConfigProperties(environment);
|
||||
Assert.assertEquals(properties.getServerAddr(), "8.8.8.8");
|
||||
Assert.assertEquals(properties.getPassword(), "123456");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.util;
|
||||
|
||||
import com.alibaba.boot.nacos.config.autoconfigure.NacosConfigAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.config.util.NacosPropertiesBuilder;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @ClassName: NacosPropertiesBuilderTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 16:49
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@TestPropertySource(properties = { "nacos.config.server-addr=localhost" })
|
||||
@SpringBootTest(classes = { NacosConfigAutoConfiguration.class })
|
||||
public class NacosPropertiesBuilderTest {
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@Test
|
||||
public void testBuildNacosProperties() {
|
||||
String serverAddr = "${nacos.config.server-addr}";
|
||||
String namespaceId = "namespaceId";
|
||||
String secretKey = "secretKey";
|
||||
String ramRoleName = "ramRoleName";
|
||||
String configLongPollTimeout = "configLongPollTimeout";
|
||||
String configRetryTimeout = "configRetryTimeout";
|
||||
String maxRetry = "maxRetry";
|
||||
String enableRemoteSyncConfig = "enableRemoteSyncConfig";
|
||||
String username = "nacos";
|
||||
String password = "password";
|
||||
Properties properties = NacosPropertiesBuilder.buildNacosProperties(environment, serverAddr, namespaceId, secretKey,
|
||||
"ak", ramRoleName, configLongPollTimeout, configRetryTimeout, maxRetry, null,enableRemoteSyncConfig, true,
|
||||
username, password);
|
||||
Assert.assertEquals(properties.size(), 12);
|
||||
Assert.assertEquals(properties.get("serverAddr"), "localhost");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMerge() {
|
||||
Properties sourceProperties = new Properties();
|
||||
sourceProperties.put("name", "SuperZ1999");
|
||||
sourceProperties.put("age", 24);
|
||||
|
||||
Properties targetProperties = new Properties();
|
||||
targetProperties.put("age", 99);
|
||||
|
||||
NacosPropertiesBuilder.merge(targetProperties, sourceProperties);
|
||||
Assert.assertEquals(targetProperties.get("name"), "SuperZ1999");
|
||||
Assert.assertEquals(targetProperties.get("age"), 99);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.util.editor;
|
||||
|
||||
import com.alibaba.boot.nacos.config.util.editor.NacosCharSequenceEditor;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @ClassName: NacosCharSequenceEditorTest
|
||||
* @Author: ChenHao26
|
||||
* @Date: 2022/8/12 17:00
|
||||
*/
|
||||
public class NacosCharSequenceEditorTest {
|
||||
|
||||
public NacosCharSequenceEditor nacosCharSequenceEditor;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
nacosCharSequenceEditor = new NacosCharSequenceEditor();
|
||||
|
||||
}
|
||||
@Test
|
||||
public void setValue() {
|
||||
nacosCharSequenceEditor.setValue("nacosTest");
|
||||
String asText = nacosCharSequenceEditor.getAsText();
|
||||
Assert.assertEquals(asText,"nacosTest");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAsText() {
|
||||
String str = nacosCharSequenceEditor.getAsText();
|
||||
Assert.assertEquals(str, "null");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.util.editor;
|
||||
|
||||
import com.alibaba.boot.nacos.config.util.editor.NacosCustomBooleanEditor;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* {@link NacosCustomBooleanEditor} Test
|
||||
* @ClassName: NacosCustomBooleanEditorTest
|
||||
* @Author: SuperZ1999
|
||||
* @Date: 2023/9/28
|
||||
*/
|
||||
public class NacosCustomBooleanEditorTest {
|
||||
@Test
|
||||
public void testAllowEmpty() {
|
||||
NacosCustomBooleanEditor booleanEditor = new NacosCustomBooleanEditor(true);
|
||||
booleanEditor.setValue("");
|
||||
Assert.assertEquals(booleanEditor.getAsText(), "false");
|
||||
|
||||
booleanEditor.setValue("true");
|
||||
Assert.assertEquals(booleanEditor.getAsText(), "true");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNotAllowEmpty() {
|
||||
NacosCustomBooleanEditor booleanEditor = new NacosCustomBooleanEditor(false);
|
||||
booleanEditor.setValue("true");
|
||||
Assert.assertEquals(booleanEditor.getAsText(), "true");
|
||||
|
||||
booleanEditor.setValue("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomBooleanString() {
|
||||
NacosCustomBooleanEditor booleanEditor = new NacosCustomBooleanEditor("TRUE", "FALSE", true);
|
||||
booleanEditor.setValue("");
|
||||
Assert.assertEquals(booleanEditor.getAsText(), "FALSE");
|
||||
|
||||
booleanEditor.setValue("TRUE");
|
||||
Assert.assertEquals(booleanEditor.getAsText(), "TRUE");
|
||||
|
||||
booleanEditor.setValue("false");
|
||||
Assert.assertEquals(booleanEditor.getAsText(), "FALSE");
|
||||
}
|
||||
}
|
|
@ -53,8 +53,7 @@
|
|||
<artifactId>nacos-client</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-config-spring-boot-autoconfigure</artifactId>
|
||||
|
@ -65,5 +64,10 @@
|
|||
<artifactId>nacos-spring-boot-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-spring-boot-aot</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
package com.alibaba.boot.nacos.discovery.actuate.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.discovery.actuate.endpoint.NacosDiscoveryEndpoint;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -35,7 +34,7 @@ public class NacosDiscoveryEndpointsAutoConfiguration {
|
|||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
@ConditionalOnAvailableEndpoint
|
||||
public NacosDiscoveryEndpoint nacosDiscoveryEndpoint() {
|
||||
return new NacosDiscoveryEndpoint();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
com.alibaba.boot.nacos.discovery.actuate.autoconfigure.NacosDiscoveryEndpointsAutoConfiguration
|
||||
com.alibaba.boot.nacos.discovery.actuate.autoconfigure.NacosDiscoveryHealthIndicatorAutoConfiguration
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.actuate.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.discovery.actuate.autoconfigure.NacosDiscoveryEndpointsAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.discovery.actuate.endpoint.NacosDiscoveryEndpoint;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* {@link NacosDiscoveryEndpointsAutoConfiguration} Test
|
||||
* @ClassName: NacosDiscoveryEndpointsAutoConfigurationTest
|
||||
* @Author: SuperZ1999
|
||||
* @Date: 2023/9/28
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = {NacosDiscoveryEndpointsAutoConfiguration.class})
|
||||
@TestPropertySource(properties = {
|
||||
"management.endpoints.web.exposure.include=nacos-discovery"
|
||||
})
|
||||
public class NacosDiscoveryEndpointsAutoConfigurationTest {
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testNacosDiscoveryEndpointBean() {
|
||||
Assert.assertNotNull(context.getBean(NacosDiscoveryEndpoint.class));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.actuate.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.discovery.actuate.autoconfigure.NacosDiscoveryHealthIndicatorAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.discovery.actuate.health.NacosDiscoveryHealthIndicator;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* {@link NacosDiscoveryHealthIndicatorAutoConfiguration} Test
|
||||
* @ClassName: NacosDiscoveryHealthIndicatorAutoConfigurationTest
|
||||
* @Author: SuperZ1999
|
||||
* @Date: 2023/9/28
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = {NacosDiscoveryHealthIndicatorAutoConfiguration.class})
|
||||
public class NacosDiscoveryHealthIndicatorAutoConfigurationTest {
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testNacosConfigHealthIndicatorBean() {
|
||||
Assert.assertNotNull(context.getBean(NacosDiscoveryHealthIndicator.class));
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
nacos.discovery.serverAddr = "127.0.0.1:8848"
|
|
@ -75,6 +75,12 @@
|
|||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-spring-boot-aot</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Test Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package com.alibaba.boot.nacos.discovery.autoconfigure;
|
||||
|
||||
import com.alibaba.boot.nacos.aot.context.EnableNacosDiscoveryAotProcessor;
|
||||
import com.alibaba.boot.nacos.discovery.NacosDiscoveryConstants;
|
||||
import com.alibaba.boot.nacos.discovery.properties.NacosDiscoveryProperties;
|
||||
import com.alibaba.nacos.spring.context.annotation.discovery.EnableNacosDiscovery;
|
||||
|
@ -26,6 +27,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import static com.alibaba.nacos.spring.util.NacosBeanUtils.DISCOVERY_GLOBAL_NACOS_PROPERTIES_BEAN_NAME;
|
||||
|
||||
|
@ -39,6 +41,7 @@ import static com.alibaba.nacos.spring.util.NacosBeanUtils.DISCOVERY_GLOBAL_NACO
|
|||
@EnableNacosDiscovery
|
||||
@EnableConfigurationProperties(value = NacosDiscoveryProperties.class)
|
||||
@ConditionalOnClass(name = "org.springframework.boot.context.properties.bind.Binder")
|
||||
@Import(EnableNacosDiscoveryAotProcessor.class)
|
||||
public class NacosDiscoveryAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
com.alibaba.boot.nacos.discovery.autoconfigure.NacosDiscoveryAutoConfiguration
|
|
@ -19,6 +19,7 @@ package com.alibaba.boot.nacos.autoconfigure;
|
|||
import java.util.Properties;
|
||||
|
||||
import com.alibaba.boot.nacos.discovery.autoconfigure.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.boot.nacos.discovery.autoconfigure.NacosDiscoveryAutoRegister;
|
||||
import com.alibaba.boot.nacos.discovery.properties.NacosDiscoveryProperties;
|
||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
|
@ -64,13 +65,13 @@ public class NacosDiscoveryAutoConfigurationTest {
|
|||
}
|
||||
|
||||
@Test(expected = NoSuchBeanDefinitionException.class)
|
||||
public void testNacosConfigGlobalBean() {
|
||||
public void testNacosDiscoveryGlobalBean() {
|
||||
Assert.assertNull(applicationContext
|
||||
.getBean(NacosBeanUtils.GLOBAL_NACOS_PROPERTIES_BEAN_NAME));
|
||||
}
|
||||
|
||||
@Test(expected = NoSuchBeanDefinitionException.class)
|
||||
public void testNacosDiscoveryGlobalBean() {
|
||||
public void testNacosConfigGlobalBean() {
|
||||
Assert.assertNull(applicationContext
|
||||
.getBean(NacosBeanUtils.CONFIG_GLOBAL_NACOS_PROPERTIES_BEAN_NAME));
|
||||
}
|
||||
|
@ -84,4 +85,8 @@ public class NacosDiscoveryAutoConfigurationTest {
|
|||
properties.getProperty(PropertyKeyConst.SERVER_ADDR));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNacosDiscoveryAutoRegister() {
|
||||
Assert.assertNotNull(applicationContext.getBean(NacosDiscoveryAutoRegister.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<artifactId>nacos-client</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-discovery-spring-boot-autoconfigure</artifactId>
|
||||
|
@ -64,5 +64,10 @@
|
|||
<artifactId>nacos-spring-boot-base</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-spring-boot-aot</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ /*
|
||||
~ * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
~ * contributor license agreements. See the NOTICE file distributed with
|
||||
~ * this work for additional information regarding copyright ownership.
|
||||
~ * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
~ * (the "License"); you may not use this file except in compliance with
|
||||
~ * the License. You may obtain a copy of the License at
|
||||
~ *
|
||||
~ * http://www.apache.org/licenses/LICENSE-2.0
|
||||
~ *
|
||||
~ * Unless required by applicable law or agreed to in writing, software
|
||||
~ * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ * See the License for the specific language governing permissions and
|
||||
~ * limitations under the License.
|
||||
~ */
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-spring-boot-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../nacos-spring-boot-parent</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>nacos-spring-boot-aot</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Nacos Spring Boot Aot</name>
|
||||
<description>Nacos Spring Boot Aot</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>${spring6.framework.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>${spring6.framework.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${spring6.framework.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-spring-context</artifactId>
|
||||
<version>${nacos-spring-context.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.aot.context;
|
||||
|
||||
import com.alibaba.boot.nacos.aot.util.AotDetector;
|
||||
import com.alibaba.nacos.spring.context.annotation.config.EnableNacosConfig;
|
||||
import com.alibaba.nacos.spring.context.annotation.config.NacosConfigBeanDefinitionRegistrar;
|
||||
import com.alibaba.nacos.spring.core.env.NacosPropertySourcePostProcessor;
|
||||
import com.alibaba.nacos.spring.util.NacosBeanUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.alibaba.nacos.spring.util.NacosBeanUtils.*;
|
||||
|
||||
/**
|
||||
* {@link EnableNacosConfig} AotProcessor
|
||||
* Except for the operation of registering BeanDefinition, all other operations in {@link NacosConfigBeanDefinitionRegistrar} must be done here
|
||||
* because spring will not call {@link NacosConfigBeanDefinitionRegistrar#registerBeanDefinitions} in AOT.
|
||||
* @author SuperZ1999
|
||||
*/
|
||||
public class EnableNacosConfigAotProcessor implements BeanDefinitionRegistryPostProcessor, EnvironmentAware, BeanFactoryAware {
|
||||
private Environment environment;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
|
||||
if (!AotDetector.useGeneratedArtifacts()) {
|
||||
return;
|
||||
}
|
||||
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) this.beanFactory;
|
||||
Map<String, Object> beansWithAnnotation = beanFactory.getBeansWithAnnotation(EnableNacosConfig.class);
|
||||
Object[] beans = beansWithAnnotation.values().toArray();
|
||||
if (beans.length != 0) {
|
||||
// only handle the first one
|
||||
Class<?> aClass = beans[0].getClass();
|
||||
if (aClass.getAnnotation(EnableNacosConfig.class) == null) {
|
||||
// cglib proxy object
|
||||
aClass = aClass.getSuperclass();
|
||||
}
|
||||
AnnotationMetadata annotationMetadata = AnnotationMetadata.introspect(aClass);
|
||||
AnnotationAttributes attributes = AnnotationAttributes
|
||||
.fromMap(annotationMetadata
|
||||
.getAnnotationAttributes(EnableNacosConfig.class.getName()));
|
||||
|
||||
// Register Global Nacos Properties Bean
|
||||
registerGlobalNacosProperties(attributes, registry, environment,
|
||||
CONFIG_GLOBAL_NACOS_PROPERTIES_BEAN_NAME);
|
||||
}
|
||||
|
||||
registerNacosConfigListenerExecutor(registry, environment);
|
||||
// replace NacosPropertySourcePostProcessor with NacosPropertySourcePostProcessorForAot
|
||||
if (registry.containsBeanDefinition(NacosPropertySourcePostProcessor.BEAN_NAME)) {
|
||||
registry.removeBeanDefinition(NacosPropertySourcePostProcessor.BEAN_NAME);
|
||||
}
|
||||
NacosBeanUtils.registerInfrastructureBeanIfAbsent(registry, NacosPropertySourcePostProcessorForAot.BEAN_NAME,
|
||||
NacosPropertySourcePostProcessorForAot.class);
|
||||
// Invoke NacosPropertySourcePostProcessor immediately
|
||||
// in order to enhance the precedence of @NacosPropertySource process
|
||||
invokeNacosPropertySourcePostProcessor(this.beanFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.aot.context;
|
||||
|
||||
import com.alibaba.boot.nacos.aot.util.AotDetector;
|
||||
import com.alibaba.nacos.spring.context.annotation.discovery.EnableNacosDiscovery;
|
||||
import com.alibaba.nacos.spring.context.annotation.discovery.NacosDiscoveryBeanDefinitionRegistrar;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.alibaba.nacos.spring.util.NacosBeanUtils.*;
|
||||
|
||||
/**
|
||||
* {@link EnableNacosDiscovery} AotProcessor
|
||||
* Except for the operation of registering BeanDefinition, all other operations in {@link NacosDiscoveryBeanDefinitionRegistrar} must be done here
|
||||
* because spring will not call {@link NacosDiscoveryBeanDefinitionRegistrar#registerBeanDefinitions} in AOT.
|
||||
* @author SuperZ1999
|
||||
*/
|
||||
public class EnableNacosDiscoveryAotProcessor implements BeanDefinitionRegistryPostProcessor, EnvironmentAware, BeanFactoryAware {
|
||||
private Environment environment;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
|
||||
if (!AotDetector.useGeneratedArtifacts()) {
|
||||
return;
|
||||
}
|
||||
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) this.beanFactory;
|
||||
Map<String, Object> beansWithAnnotation = beanFactory.getBeansWithAnnotation(EnableNacosDiscovery.class);
|
||||
Object[] beans = beansWithAnnotation.values().toArray();
|
||||
if (beans.length != 0) {
|
||||
// only handle the first one
|
||||
Class<?> aClass = beans[0].getClass();
|
||||
if (aClass.getAnnotation(EnableNacosDiscovery.class) == null) {
|
||||
// cglib proxy object
|
||||
aClass = aClass.getSuperclass();
|
||||
}
|
||||
AnnotationMetadata annotationMetadata = AnnotationMetadata.introspect(aClass);
|
||||
AnnotationAttributes attributes = AnnotationAttributes
|
||||
.fromMap(annotationMetadata
|
||||
.getAnnotationAttributes(EnableNacosDiscovery.class.getName()));
|
||||
|
||||
// Register Global Nacos Properties Bean
|
||||
registerGlobalNacosProperties(attributes, registry, environment,
|
||||
DISCOVERY_GLOBAL_NACOS_PROPERTIES_BEAN_NAME);
|
||||
registerGlobalNacosProperties(attributes, registry, environment,
|
||||
MAINTAIN_GLOBAL_NACOS_PROPERTIES_BEAN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.aot.context;
|
||||
|
||||
import com.alibaba.boot.nacos.aot.util.AotDetector;
|
||||
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
|
||||
import com.alibaba.nacos.spring.core.env.AbstractNacosPropertySourceBuilder;
|
||||
import com.alibaba.nacos.spring.core.env.NacosPropertySourcePostProcessor;
|
||||
import com.alibaba.spring.util.BeanUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.alibaba.nacos.spring.util.NacosBeanUtils.getConfigServiceBeanBuilder;
|
||||
|
||||
public class NacosPropertySourcePostProcessorForAot extends NacosPropertySourcePostProcessor {
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
|
||||
throws BeansException {
|
||||
String[] abstractNacosPropertySourceBuilderBeanNames = BeanUtils
|
||||
.getBeanNames(beanFactory, AbstractNacosPropertySourceBuilder.class);
|
||||
|
||||
this.nacosPropertySourceBuilders = new ArrayList<AbstractNacosPropertySourceBuilder>(
|
||||
abstractNacosPropertySourceBuilderBeanNames.length);
|
||||
|
||||
for (String beanName : abstractNacosPropertySourceBuilderBeanNames) {
|
||||
this.nacosPropertySourceBuilders.add(beanFactory.getBean(beanName,
|
||||
AbstractNacosPropertySourceBuilder.class));
|
||||
}
|
||||
|
||||
NacosPropertySourcePostProcessor.beanFactory = beanFactory;
|
||||
this.configServiceBeanBuilder = getConfigServiceBeanBuilder(beanFactory);
|
||||
|
||||
if (AotDetector.useGeneratedArtifacts()) {
|
||||
// the type of all BeanDefinitions is RootBeanDefinition in AOT, but what we need is AnnotatedGenericBeanDefinition.
|
||||
Map<String, Object> beansWithAnnotation = beanFactory.getBeansWithAnnotation(NacosPropertySource.class);
|
||||
for (Map.Entry<String, Object> entry : beansWithAnnotation.entrySet()) {
|
||||
processPropertySourceForAot(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
String[] beanNames = beanFactory.getBeanDefinitionNames();
|
||||
|
||||
for (String beanName : beanNames) {
|
||||
processPropertySource(beanName, beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
private void processPropertySourceForAot(String beanName, Object bean) {
|
||||
if (processedBeanNames.contains(beanName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BeanDefinition beanDefinition = null;
|
||||
Class<?> aClass = bean.getClass();
|
||||
NacosPropertySource[] annotations = aClass.getSuperclass().getAnnotationsByType(NacosPropertySource.class);
|
||||
if (annotations.length != 0) {
|
||||
beanDefinition = new AnnotatedGenericBeanDefinition(aClass.getSuperclass());
|
||||
}
|
||||
annotations = aClass.getAnnotationsByType(NacosPropertySource.class);
|
||||
if (annotations.length != 0) {
|
||||
beanDefinition = new AnnotatedGenericBeanDefinition(aClass);
|
||||
}
|
||||
|
||||
doProcessPropertySource(beanName, beanDefinition);
|
||||
|
||||
processedBeanNames.add(beanName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.aot.hint;
|
||||
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.config.annotation.NacosValue;
|
||||
import org.springframework.aot.generate.GenerationContext;
|
||||
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
|
||||
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
|
||||
import org.springframework.beans.factory.aot.BeanRegistrationCode;
|
||||
import org.springframework.beans.factory.support.RegisteredBean;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link NacosInjected} and {@link NacosValue} AotProcessor
|
||||
* The fields annotated with {@link NacosInjected} or {@link NacosValue} must be added to the reflect-config.json
|
||||
* @author SuperZ1999
|
||||
*/
|
||||
public class NacosAnnotationBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
|
||||
@Override
|
||||
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
||||
Class<?> beanClass = registeredBean.getBeanClass();
|
||||
List<Field> fields = new ArrayList<>();
|
||||
ReflectionUtils.doWithFields(beanClass, field -> {
|
||||
NacosInjected injectedAnnotation = field.getDeclaredAnnotation(NacosInjected.class);
|
||||
NacosValue nacosValueAnnotation = field.getDeclaredAnnotation(NacosValue.class);
|
||||
if (injectedAnnotation != null || nacosValueAnnotation != null) {
|
||||
fields.add(field);
|
||||
}
|
||||
});
|
||||
if (fields.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new AotContribution(fields);
|
||||
}
|
||||
|
||||
private static class AotContribution implements BeanRegistrationAotContribution {
|
||||
private final List<Field> fields;
|
||||
|
||||
public AotContribution() {
|
||||
this.fields = new ArrayList<>();
|
||||
}
|
||||
|
||||
public AotContribution(List<Field> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) {
|
||||
for (Field field : fields) {
|
||||
generationContext.getRuntimeHints().reflection().registerField(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.aot.util;
|
||||
|
||||
import org.springframework.core.NativeDetector;
|
||||
import org.springframework.core.SpringProperties;
|
||||
|
||||
public abstract class AotDetector {
|
||||
|
||||
/**
|
||||
* System property that indicates the application should run with AOT
|
||||
* generated artifacts. If such optimizations are not available, it is
|
||||
* recommended to throw an exception rather than fall back to the regular
|
||||
* runtime behavior.
|
||||
*/
|
||||
public static final String AOT_ENABLED = "spring.aot.enabled";
|
||||
|
||||
/**
|
||||
* Determine whether AOT optimizations must be considered at runtime. This
|
||||
* is mandatory in a native image but can be triggered on the JVM using
|
||||
* the {@value #AOT_ENABLED} Spring property.
|
||||
* @return whether AOT optimizations must be considered
|
||||
*/
|
||||
public static boolean useGeneratedArtifacts() {
|
||||
return (NativeDetector.inNativeImage() || SpringProperties.getFlag(AOT_ENABLED));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.aot.util;
|
||||
|
||||
public abstract class NativeDetector {
|
||||
|
||||
// See https://github.com/oracle/graal/blob/master/sdk/src/org.graalvm.nativeimage/src/org/graalvm/nativeimage/ImageInfo.java
|
||||
private static final boolean imageCode = (System.getProperty("org.graalvm.nativeimage.imagecode") != null);
|
||||
|
||||
/**
|
||||
* Returns {@code true} if invoked in the context of image building or during image runtime, else {@code false}.
|
||||
*/
|
||||
public static boolean inNativeImage() {
|
||||
return imageCode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
{
|
||||
"name": "com.alibaba.boot.nacos.aot.context.NacosPropertySourcePostProcessorForAot",
|
||||
"allDeclaredClasses": true,
|
||||
"allDeclaredMethods": true,
|
||||
"allDeclaredFields": true,
|
||||
"allDeclaredConstructors": true
|
||||
}
|
||||
]
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"resources": {
|
||||
"includes": [
|
||||
{
|
||||
"pattern": "\\QMETA-INF/spring.handlers\\E"
|
||||
},
|
||||
{
|
||||
"pattern": "\\QMETA-INF/spring.schemas\\E"
|
||||
},
|
||||
{
|
||||
"pattern": "\\QMETA-INF/schemas/nacos.xsd\\E"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
org.springframework.beans.factory.aot.BeanRegistrationAotProcessor=\
|
||||
com.alibaba.boot.nacos.aot.hint.NacosAnnotationBeanRegistrationAotProcessor
|
|
@ -0,0 +1 @@
|
|||
com.alibaba.boot.nacos.common.NacosFailureAnalyzer
|
|
@ -35,8 +35,9 @@
|
|||
<java.target.version>1.8</java.target.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.0.3.RELEASE</spring-boot.version>
|
||||
<nacos-spring-context.version>1.1.0</nacos-spring-context.version>
|
||||
<spring-boot.version>2.6.3</spring-boot.version>
|
||||
<spring6.framework.version>6.0.8</spring6.framework.version>
|
||||
<nacos-spring-context.version>2.1.0-RC</nacos-spring-context.version>
|
||||
<!-- Build args -->
|
||||
<argline>-server -Xms256m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=128m -Dfile.encoding=UTF-8
|
||||
-Djava.net.preferIPv4Stack=true
|
||||
|
@ -52,7 +53,7 @@
|
|||
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
|
||||
<nacos.version>2.0.2</nacos.version>
|
||||
<nacos.version>2.2.1</nacos.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -85,13 +86,19 @@
|
|||
<artifactId>nacos-client</artifactId>
|
||||
<version>${nacos.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-spring-boot-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-spring-boot-aot</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-config-spring-boot-autoconfigure</artifactId>
|
||||
|
@ -169,6 +176,16 @@
|
|||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- Used for packaging NOTICE & LICENSE to each sub-module jar-->
|
||||
<resources>
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ /*
|
||||
~ * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
~ * contributor license agreements. See the NOTICE file distributed with
|
||||
~ * this work for additional information regarding copyright ownership.
|
||||
~ * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
~ * (the "License"); you may not use this file except in compliance with
|
||||
~ * the License. You may obtain a copy of the License at
|
||||
~ *
|
||||
~ * http://www.apache.org/licenses/LICENSE-2.0
|
||||
~ *
|
||||
~ * Unless required by applicable law or agreed to in writing, software
|
||||
~ * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ * See the License for the specific language governing permissions and
|
||||
~ * limitations under the License.
|
||||
~ */
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-spring-boot-samples</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>nacos-aot-sample</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Nacos Spring Boot Aot Sample</name>
|
||||
<description>Nacos Spring Boot Aot Sample</description>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.boot</groupId>
|
||||
<artifactId>nacos-discovery-spring-boot-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>native</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.graalvm.buildtools</groupId>
|
||||
<artifactId>native-maven-plugin</artifactId>
|
||||
<version>0.9.25</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
|
||||
<mainClass>com.alibaba.boot.nacos.sample.AotApplication</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>process-aot</id>
|
||||
<goals>
|
||||
<goal>process-aot</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.sample;
|
||||
|
||||
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@NacosPropertySource(dataId = "example", autoRefreshed = true)
|
||||
public class AotApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AotApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
*
|
||||
* * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* * contributor license agreements. See the NOTICE file distributed with
|
||||
* * this work for additional information regarding copyright ownership.
|
||||
* * The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* * (the "License"); you may not use this file except in compliance with
|
||||
* * the License. You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* * See the License for the specific language governing permissions and
|
||||
* * limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.alibaba.boot.nacos.sample.controller;
|
||||
|
||||
import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.alibaba.nacos.api.config.annotation.NacosValue;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||
|
||||
@Controller
|
||||
public class AotController {
|
||||
@NacosInjected
|
||||
private ConfigService configService;
|
||||
|
||||
@NacosInjected
|
||||
private NamingService namingService;
|
||||
|
||||
@NacosValue(value = "${flag:false}", autoRefreshed = true)
|
||||
private boolean flag;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/config/get", method = GET)
|
||||
public String getConfig() throws NacosException {
|
||||
return configService.getConfig("example", "DEFAULT_GROUP", 5000);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/naming/get", method = GET)
|
||||
public List<Instance> getNaming(@RequestParam("serviceName") String serviceName) throws NacosException {
|
||||
return namingService.getAllInstances(serviceName);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/flag/get", method = GET)
|
||||
public boolean getFlag() {
|
||||
return flag;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
[
|
||||
{
|
||||
"name":"[Lcom.sun.management.internal.DiagnosticCommandArgumentInfo;"
|
||||
},
|
||||
{
|
||||
"name":"[Lcom.sun.management.internal.DiagnosticCommandInfo;"
|
||||
},
|
||||
{
|
||||
"name":"com.sun.management.internal.DiagnosticCommandArgumentInfo",
|
||||
"methods":[{"name":"<init>","parameterTypes":["java.lang.String","java.lang.String","java.lang.String","java.lang.String","boolean","boolean","boolean","int"] }]
|
||||
},
|
||||
{
|
||||
"name":"com.sun.management.internal.DiagnosticCommandInfo",
|
||||
"methods":[{"name":"<init>","parameterTypes":["java.lang.String","java.lang.String","java.lang.String","java.lang.String","java.lang.String","java.lang.String","boolean","java.util.List"] }]
|
||||
},
|
||||
{
|
||||
"name":"java.lang.Boolean",
|
||||
"methods":[{"name":"getBoolean","parameterTypes":["java.lang.String"] }]
|
||||
},
|
||||
{
|
||||
"name":"java.lang.InternalError",
|
||||
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
|
||||
},
|
||||
{
|
||||
"name":"java.util.Arrays",
|
||||
"methods":[{"name":"asList","parameterTypes":["java.lang.Object[]"] }]
|
||||
},
|
||||
{
|
||||
"name":"sun.instrument.InstrumentationImpl",
|
||||
"methods":[{"name":"<init>","parameterTypes":["long","boolean","boolean"] }, {"name":"loadClassAndCallAgentmain","parameterTypes":["java.lang.String","java.lang.String"] }, {"name":"loadClassAndCallPremain","parameterTypes":["java.lang.String","java.lang.String"] }, {"name":"transform","parameterTypes":["java.lang.Module","java.lang.ClassLoader","java.lang.String","java.lang.Class","java.security.ProtectionDomain","byte[]","boolean"] }]
|
||||
},
|
||||
{
|
||||
"name":"sun.management.VMManagementImpl",
|
||||
"fields":[{"name":"compTimeMonitoringSupport"}, {"name":"currentThreadCpuTimeSupport"}, {"name":"objectMonitorUsageSupport"}, {"name":"otherThreadCpuTimeSupport"}, {"name":"remoteDiagnosticCommandsSupport"}, {"name":"synchronizerUsageSupport"}, {"name":"threadAllocatedMemorySupport"}, {"name":"threadContentionMonitoringSupport"}]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,8 @@
|
|||
[
|
||||
{
|
||||
"type":"agent-extracted",
|
||||
"classes":[
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
[
|
||||
{
|
||||
"interfaces":["java.lang.reflect.ParameterizedType","org.springframework.core.SerializableTypeWrapper$SerializableTypeProxy","java.io.Serializable"]
|
||||
},
|
||||
{
|
||||
"interfaces":["java.lang.reflect.TypeVariable","org.springframework.core.SerializableTypeWrapper$SerializableTypeProxy","java.io.Serializable"]
|
||||
},
|
||||
{
|
||||
"interfaces":["java.lang.reflect.WildcardType","org.springframework.core.SerializableTypeWrapper$SerializableTypeProxy","java.io.Serializable"]
|
||||
},
|
||||
{
|
||||
"interfaces":["org.springframework.boot.context.properties.ConfigurationProperties"]
|
||||
},
|
||||
{
|
||||
"interfaces":["org.springframework.web.bind.annotation.RequestMapping"]
|
||||
},
|
||||
{
|
||||
"interfaces":["org.springframework.web.bind.annotation.RequestParam"]
|
||||
}
|
||||
]
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,440 @@
|
|||
{
|
||||
"resources":{
|
||||
"includes":[{
|
||||
"pattern":"\\QMETA-INF/services/ch.qos.logback.classic.spi.Configurator\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/services/com.alibaba.nacos.api.config.filter.IConfigFilter\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/services/com.alibaba.nacos.api.remote.Payload\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/services/com.alibaba.nacos.common.log.NacosLogbackConfigurator\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/services/com.alibaba.nacos.plugin.auth.spi.client.AbstractClientAuthService\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/services/com.alibaba.nacos.shaded.io.grpc.LoadBalancerProvider\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/services/com.alibaba.nacos.shaded.io.grpc.ManagedChannelProvider\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/services/com.alibaba.nacos.shaded.io.grpc.NameResolverProvider\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/services/com.alibaba.nacos.spring.util.ConfigParse\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/services/org.slf4j.spi.SLF4JServiceProvider\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/spring-autoconfigure-metadata.properties\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/spring.factories\\E"
|
||||
}, {
|
||||
"pattern":"\\QMETA-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports\\E"
|
||||
}, {
|
||||
"pattern":"\\Qapplication.properties\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/aot/context/EnableNacosConfigAotProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/aot/context/EnableNacosDiscoveryAotProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/common/NacosFailureAnalyzer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/config/autoconfigure/NacosConfigAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/config/autoconfigure/NacosConfigBootBeanDefinitionRegistrar.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/config/autoconfigure/NacosConfigEnvironmentProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/config/logging/NacosLoggingListener.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/config/support/MultiProfilesYamlConfigParseSupport.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/discovery/autoconfigure/NacosDiscoveryAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/sample/\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/boot/nacos/sample/controller/AotController.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/nacos/spring/context/annotation/config/EnableNacosConfig.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/nacos/spring/context/annotation/config/NacosConfigBeanDefinitionRegistrar.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/nacos/spring/context/annotation/discovery/EnableNacosDiscovery.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/nacos/spring/context/annotation/discovery/NacosDiscoveryBeanDefinitionRegistrar.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/nacos/spring/util/AbstractConfigParse.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/nacos/spring/util/ConfigParse.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qcom/alibaba/nacos/spring/util/parse/DefaultYamlConfigParse.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qnacos-version.txt\\E"
|
||||
}, {
|
||||
"pattern":"\\Qnacos_default_setting.properties\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/apache/catalina/core/RestrictedFilters.properties\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/apache/catalina/core/RestrictedListeners.properties\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/apache/catalina/core/RestrictedServlets.properties\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/apache/catalina/loader/JdbcLeakPrevention.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/apache/catalina/util/CharsetMapperDefault.properties\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/apache/catalina/util/ServerInfo.properties\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/beans/factory/Aware.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/beans/factory/BeanFactoryAware.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/beans/factory/config/BeanFactoryPostProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/beans/factory/support/BeanDefinitionRegistryPostProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/AbstractDependsOnBeanFactoryPostProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/AutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/AutoConfigureAfter.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/AutoConfigureBefore.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/AutoConfigureOrder.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/aop/AopAutoConfiguration$AspectJAutoProxyingConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/aop/AopAutoConfiguration$ClassProxyingConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/aop/AopAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/cache/CacheAutoConfiguration$CacheConfigurationImportSelector.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/cache/CacheAutoConfiguration$CacheManagerEntityManagerFactoryDependsOnPostProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/cache/CacheAutoConfiguration$CacheManagerValidator.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/cache/GenericCacheConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/cache/NoOpCacheConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/cache/SimpleCacheConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/condition/ConditionalOnBean.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/condition/ConditionalOnClass.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/condition/ConditionalOnMissingBean.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/condition/ConditionalOnMissingClass.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/condition/ConditionalOnNotWarDeployment.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/condition/ConditionalOnProperty.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/condition/ConditionalOnWebApplication.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/context/LifecycleAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/context/MessageSourceAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/context/PropertyPlaceholderAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/GsonHttpMessageConvertersConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration$HttpMessageConvertersAutoConfigurationRuntimeHints.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration$NotReactiveWebApplicationCondition$ReactiveWebApplication.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration$NotReactiveWebApplicationCondition.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/JacksonHttpMessageConvertersConfiguration$MappingJackson2XmlHttpMessageConverterConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/JacksonHttpMessageConvertersConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/http/JsonbHttpMessageConvertersConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration$GitResourceAvailableCondition.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration$StandardJackson2ObjectMapperBuilderCustomizer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonAutoConfigurationRuntimeHints.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonMixinConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$ParameterNamesModuleConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryDependsOnPostProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/sql/init/R2dbcInitializationConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/sql/init/SqlInitializationAutoConfiguration$SqlInitializationModeCondition$ModeIsNever.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/sql/init/SqlInitializationAutoConfiguration$SqlInitializationModeCondition.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/sql/init/SqlInitializationAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration$NotReactiveWebApplicationCondition$ReactiveWebApplication.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration$NotReactiveWebApplicationCondition.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration$JettyWebServerFactoryCustomizerConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration$NettyWebServerFactoryCustomizerConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration$TomcatWebServerFactoryCustomizerConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration$UndertowWebServerFactoryCustomizerConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DefaultDispatcherServletCondition.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DispatcherServletConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DispatcherServletRegistrationCondition.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration$LocaleCharsetMappingsCustomizer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration$BeanPostProcessorsRegistrar.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration$ForwardedHeaderFilterConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration$ForwardedHeaderFilterCustomizer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedJetty.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedUndertow.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$OptionalPathExtensionContentNegotiationStrategy.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$ProblemDetailsErrorHandlingConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$ResourceChainCustomizerConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$ResourceChainResourceHandlerRegistrationCustomizer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$ResourceHandlerRegistrationCustomizer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration$DefaultErrorViewResolverConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration$ErrorPageCustomizer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration$ErrorTemplateMissingCondition.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration$PreserveErrorControllerTargetClassPostProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration$StaticView.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration$JettyWebSocketConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration$TomcatWebSocketConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration$UndertowWebSocketConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/context/properties/EnableConfigurationProperties.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/context/properties/EnableConfigurationPropertiesRegistrar.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/diagnostics/AbstractFailureAnalyzer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/diagnostics/FailureAnalyzer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/env/EnvironmentPostProcessor.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/boot/sql/init/dependency/DatabaseInitializationDependencyConfigurer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/ApplicationContextAware.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/ApplicationListener.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/EnvironmentAware.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/ResourceLoaderAware.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/annotation/Conditional.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/annotation/Configuration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/annotation/Import.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/annotation/ImportBeanDefinitionRegistrar.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/annotation/ImportRuntimeHints.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/event/GenericApplicationListener.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/context/event/SmartApplicationListener.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/core/Ordered.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/core/annotation/Order.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/web/context/ServletContextAware.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport$NoOpValidator.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/web/servlet/config/annotation/WebMvcConfigurer.class\\E"
|
||||
}, {
|
||||
"pattern":"\\Qorg/springframework/web/util/HtmlCharacterEntityReferences.properties\\E"
|
||||
}]},
|
||||
"bundles":[{
|
||||
"name":"jakarta.servlet.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"jakarta.servlet.http.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.authenticator.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.authenticator.jaspic.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.connector.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.core.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.deploy.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.loader.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.mapper.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.mbeans.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.realm.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.security.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.session.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.startup.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.util.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.valves.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.catalina.webresources.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.coyote.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.coyote.http11.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.coyote.http11.filters.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.naming.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.buf.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.compat.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.descriptor.web.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.http.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.http.parser.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.modeler.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.net.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.scan.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.util.threads.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.websocket.LocalStrings",
|
||||
"locales":[""]
|
||||
}, {
|
||||
"name":"org.apache.tomcat.websocket.server.LocalStrings",
|
||||
"locales":[""]
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"types":[
|
||||
{
|
||||
"name":"java.rmi.server.RemoteObject"
|
||||
},
|
||||
{
|
||||
"name":"java.rmi.server.RemoteStub"
|
||||
},
|
||||
{
|
||||
"name":"javax.management.remote.rmi.RMIServerImpl_Stub"
|
||||
}
|
||||
],
|
||||
"lambdaCapturingTypes":[
|
||||
],
|
||||
"proxies":[
|
||||
]
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
nacos.config.server-addr=localhost:8848
|
||||
nacos.discovery.server-addr=localhost:8848
|
|
@ -38,7 +38,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.1.6.RELEASE</version>
|
||||
<version>2.5.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.springframework.boot.logging.LoggingSystem;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* print logger
|
||||
* @author <a href="mailto:liaochunyhm@live.com">liaochuntao</a>
|
||||
* @since
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<modules>
|
||||
<module>nacos-config-sample</module>
|
||||
<module>nacos-discovery-sample</module>
|
||||
<module>nacos-aot-sample</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -8,7 +8,7 @@
|
|||
<version>7</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<revision>0.2.9</revision>
|
||||
<revision>0.3.0-RC</revision>
|
||||
<maven_javadoc_version>3.0.1</maven_javadoc_version>
|
||||
<maven_surefire_version>2.19.1</maven_surefire_version>
|
||||
<maven-source-plugin.version>3.1.0</maven-source-plugin.version>
|
||||
|
@ -35,6 +35,7 @@
|
|||
<module>nacos-discovery-spring-boot-starter</module>
|
||||
<module>nacos-discovery-spring-boot-actuator</module>
|
||||
<module>nacos-spring-boot-samples</module>
|
||||
<module>nacos-spring-boot-aot</module>
|
||||
</modules>
|
||||
|
||||
<organization>
|
||||
|
@ -76,6 +77,9 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<configuration>
|
||||
<doclint>none</doclint>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
|
@ -160,4 +164,4 @@
|
|||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue