Skip to content

Commit 3e184db

Browse files
重新命名项目模块
1 parent 921206c commit 3e184db

File tree

80 files changed

+232
-57
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+232
-57
lines changed

README.md

+10-13

formatter-sunhome-spring-boot-starter/pom.xml formatter-spring-boot-starter/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
6-
<artifactId>sunhome-spring-boot</artifactId>
6+
<artifactId>spring-boot-project</artifactId>
77
<groupId>com.sunhome.boot</groupId>
88
<version>1.0.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>formatter-sunhome-spring-boot-starter</artifactId>
12+
<artifactId>formatter-spring-boot-starter</artifactId>
1313
<packaging>jar</packaging>
1414

1515

pom.xml

+12-11
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,23 @@
1111
<modelVersion>4.0.0</modelVersion>
1212

1313
<groupId>com.sunhome.boot</groupId>
14-
<artifactId>sunhome-spring-boot</artifactId>
14+
<artifactId>spring-boot-project</artifactId>
1515
<version>1.0.0-SNAPSHOT</version>
1616
<packaging>pom</packaging>
1717

18-
<name>sunhome-spring-boot</name>
19-
<description>sunhome-boot 依赖管理</description>
18+
<name>spring-boot</name>
19+
<description>boot 依赖管理</description>
2020

2121
<modules>
22-
<module>sunhome-spring-boot-first-application</module>
23-
<module>sunhome-spring-boot-configuration</module>
24-
<module>sunhome-spring-boot-import</module>
25-
<module>sunhome-spring-boot-alias-annotation</module>
26-
<module>sunhome-spring-boot-actuator</module>
27-
<module>sunhome-spring-boot-enable</module>
28-
<module>formatter-sunhome-spring-boot-starter</module>
29-
<module>sunhome-spring-boot-prometheus-simularor</module>
22+
<module>spring-boot-first-application-sample</module>
23+
<module>spring-boot-configuration-sample</module>
24+
<module>spring-boot-import-sample</module>
25+
<module>spring-boot-alias-annotation-sample</module>
26+
<module>spring-boot-actuator-sample</module>
27+
<module>spring-boot-enable-sample</module>
28+
<module>formatter-spring-boot-starter</module>
29+
<module>spring-boot-prometheus-simularor-sample</module>
30+
<module>spring-boot-context-sample</module>
3031
</modules>
3132

3233

sunhome-spring-boot-actuator/pom.xml spring-boot-actuator-sample/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
6-
<artifactId>sunhome-spring-boot</artifactId>
6+
<artifactId>spring-boot-project</artifactId>
77
<groupId>com.sunhome.boot</groupId>
88
<version>1.0.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>sunhome-spring-boot-actuator</artifactId>
13-
<name>sunhome-spring-boot-actuator</name>
12+
<artifactId>spring-boot-actuator-sample</artifactId>
13+
1414

1515
<dependencies>
1616
<!--添加spring boot 基础依赖-->

sunhome-spring-boot-actuator/src/main/java/com/sunhome/boot/actuator/ActuatorApplication.java spring-boot-actuator-sample/src/main/java/com/sunhome/boot/actuator/ActuatorApplication.java

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33

44
import com.sunhome.boot.actuator.endpoint.CustomEndpoint;
5+
import io.micrometer.core.aop.TimedAspect;
6+
import io.micrometer.core.instrument.MeterRegistry;
57
import org.springframework.boot.SpringApplication;
68
import org.springframework.boot.autoconfigure.SpringBootApplication;
79
import org.springframework.context.annotation.Bean;
@@ -21,5 +23,15 @@ public CustomEndpoint customEndpoint() {
2123
return new CustomEndpoint();
2224
}
2325

26+
/**
27+
* 开启timed切面
28+
* @param registry
29+
* @return
30+
*/
31+
@Bean
32+
public TimedAspect timedAspect(MeterRegistry registry) {
33+
return new TimedAspect(registry);
34+
}
35+
2436

2537
}

sunhome-spring-boot-actuator/src/main/java/com/sunhome/boot/actuator/aspect/HttpMethodCostAspect.java spring-boot-actuator-sample/src/main/java/com/sunhome/boot/actuator/aspect/HttpMethodCostAspect.java

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.sunhome.boot.actuator.aspect;
22

33
import com.sunhome.boot.actuator.annotation.RequestRate;
4-
import io.micrometer.core.instrument.MeterRegistry;
54
import io.micrometer.core.instrument.Timer;
6-
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
75
import io.micrometer.prometheus.PrometheusMeterRegistry;
86
import org.aspectj.lang.ProceedingJoinPoint;
97
import org.aspectj.lang.annotation.Around;
@@ -13,7 +11,6 @@
1311
import org.springframework.beans.factory.annotation.Autowired;
1412
import org.springframework.stereotype.Component;
1513
import org.springframework.util.ClassUtils;
16-
import org.springframework.util.StringUtils;
1714

1815
import java.lang.reflect.Method;
1916

sunhome-spring-boot-actuator/src/main/java/com/sunhome/boot/actuator/controller/ActuatorController.java spring-boot-actuator-sample/src/main/java/com/sunhome/boot/actuator/controller/ActuatorController.java

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.sunhome.boot.actuator.controller;
22

33
import com.sunhome.boot.actuator.annotation.RequestRate;
4+
import io.micrometer.core.annotation.Timed;
45
import org.springframework.web.bind.annotation.GetMapping;
56
import org.springframework.web.bind.annotation.RequestParam;
67
import org.springframework.web.bind.annotation.RestController;
@@ -17,4 +18,17 @@ public class ActuatorController {
1718
public String hello(@RequestParam(name = "name", required = false, defaultValue = "doge") String name) {
1819
return String.format("%s say hello!", name);
1920
}
21+
22+
/**
23+
* 使用自带注解
24+
*
25+
* @param test
26+
* @return
27+
*/
28+
@Timed(extraTags = {"name", "fsdfs"})
29+
@GetMapping(value = "/test")
30+
public String test(String test) {
31+
return String.format("%s say hello!", test);
32+
33+
}
2034
}

sunhome-spring-boot-actuator/src/main/resources/application.properties spring-boot-actuator-sample/src/main/resources/application.properties

+3
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ management.endpoint.prometheus.enabled=true
1212
management.metrics.export.prometheus.enabled=true
1313

1414

15+
management.metrics.web.server.auto-time-requests=false
16+
17+
1518
info.app.name=sunhome-spring-boot-actuator
1619
info.app.version=1.0.0

sunhome-spring-boot-alias-annotation/pom.xml spring-boot-alias-annotation-sample/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
6-
<artifactId>sunhome-spring-boot</artifactId>
6+
<artifactId>spring-boot-project</artifactId>
77
<groupId>com.sunhome.boot</groupId>
88
<version>1.0.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>sunhome-spring-boot-alias-annotation</artifactId>
12+
<artifactId>spring-boot-alias-annotation-sample</artifactId>
1313
<description>spring 注解属性别名模块</description>
1414

1515
<dependencies>

sunhome-spring-boot-configuration/pom.xml spring-boot-configuration-sample/pom.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55
<parent>
66
<groupId>com.sunhome.boot</groupId>
7-
<artifactId>sunhome-spring-boot</artifactId>
7+
<artifactId>spring-boot-project</artifactId>
88
<version>1.0.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<groupId>com.sunhome.boot</groupId>
13-
<artifactId>sunhome-spring-boot-configuration</artifactId>
13+
<artifactId>spring-boot-configuration-sample</artifactId>
1414
<packaging>jar</packaging>
15-
<name>sunhome-spring-boot-configuration</name>
1615
<description>配置加载模块</description>
1716

1817
<dependencies>

spring-boot-context-sample/pom.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>spring-boot-project</artifactId>
7+
<groupId>com.sunhome.boot</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>spring-boot-context-sample</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.springframework.boot</groupId>
17+
<artifactId>spring-boot-starter-web</artifactId>
18+
</dependency>
19+
</dependencies>
20+
21+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.sunhome.boot.context;
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
import org.springframework.boot.builder.SpringApplicationBuilder;
5+
6+
/**
7+
* @author wangqijia
8+
* @date 2019/11/18 12:53
9+
*/
10+
@SpringBootApplication
11+
public class EventBootstrap {
12+
13+
public static void main(String[] args) {
14+
new SpringApplicationBuilder()
15+
.sources(EventBootstrap.class)
16+
.run(args);
17+
18+
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.sunhome.boot.context.controller;
2+
3+
import com.sunhome.boot.context.event.ConfigChangeEvent;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.context.ApplicationEventPublisher;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
import java.util.HashMap;
10+
import java.util.Map;
11+
12+
/**
13+
* @author wangqijia
14+
* @date 2019/11/18 13:52
15+
*/
16+
@RestController
17+
public class EventController {
18+
19+
@Autowired
20+
private ApplicationEventPublisher eventPublisher;
21+
22+
@GetMapping("/config/publish")
23+
public String publish() {
24+
Map<String, Object> configMap = new HashMap<>();
25+
configMap.put("name", "lisha");
26+
configMap.put("age", "18");
27+
eventPublisher.publishEvent(new ConfigChangeEvent(configMap));
28+
return "ok";
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.sunhome.boot.context.event;
2+
3+
import org.springframework.context.ApplicationEvent;
4+
5+
import java.util.Map;
6+
7+
/**
8+
* @author wangqijia
9+
* @date 2019/11/18 13:28
10+
*/
11+
public class ConfigChangeEvent extends ApplicationEvent {
12+
13+
public ConfigChangeEvent(Map<String, Object> source) {
14+
super(source);
15+
}
16+
17+
public Map<String, Object> getConfigChangeInfo() {
18+
return (Map) getSource();
19+
}
20+
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.sunhome.boot.context.event;
2+
3+
import org.springframework.context.ApplicationListener;
4+
import org.springframework.context.event.EventListener;
5+
import org.springframework.stereotype.Component;
6+
7+
import java.util.Map;
8+
9+
/**
10+
* @author wangqijia
11+
* @date 2019/11/18 13:42
12+
*/
13+
@Component
14+
public class ConfigChangeListener implements ApplicationListener<ConfigChangeEvent> {
15+
16+
@Override
17+
public void onApplicationEvent(ConfigChangeEvent event) {
18+
System.out.println(" impl ApplicationListener 声明");
19+
20+
Map<String, Object> configChangeInfo = event.getConfigChangeInfo();
21+
configChangeInfo.forEach((key, value) -> {
22+
System.out.printf("key:%s value:%s\n", key, value);
23+
});
24+
}
25+
26+
@EventListener(value = ConfigChangeEvent.class)
27+
void onConfigChangeEvent(ConfigChangeEvent event) {
28+
System.out.println(" @EventListener 声明");
29+
Map<String, Object> configChangeInfo = event.getConfigChangeInfo();
30+
configChangeInfo.forEach((key, value) -> {
31+
System.out.printf("key:%s value:%s\n", key, value);
32+
});
33+
}
34+
}

sunhome-spring-boot-enable/pom.xml spring-boot-enable-sample/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
6-
<artifactId>sunhome-spring-boot</artifactId>
6+
<artifactId>spring-boot-project</artifactId>
77
<groupId>com.sunhome.boot</groupId>
88
<version>1.0.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>sunhome-spring-boot-enable</artifactId>
12+
<artifactId>spring-boot-enable-sample</artifactId>
1313

1414
<dependencies>
1515
<!--添加spring boot 基础依赖-->

sunhome-spring-boot-first-application/pom.xml spring-boot-first-application-sample/pom.xml

+4-11
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5+
56
<parent>
67
<groupId>com.sunhome.boot</groupId>
7-
<artifactId>sunhome-spring-boot</artifactId>
8+
<artifactId>spring-boot-project</artifactId>
89
<version>1.0.0-SNAPSHOT</version>
910
</parent>
1011

11-
12-
<groupId>com.sunhome.boot</groupId>
13-
<artifactId>sunhome-spring-boot-first-application</artifactId>
14-
<name>sunhome-spring-boot-first-application</name>
15-
<description>构建第一个spring-boot项目 测试demo</description>
16-
17-
<properties>
18-
<java.version>1.8</java.version>
19-
</properties>
12+
<artifactId>spring-boot-first-application-sample</artifactId>
2013

2114
<dependencies>
2215
<dependency>
@@ -32,7 +25,7 @@
3225
<!--依赖格式starter模块-->
3326
<dependency>
3427
<groupId>com.sunhome.boot</groupId>
35-
<artifactId>formatter-sunhome-spring-boot-starter</artifactId>
28+
<artifactId>formatter-spring-boot-starter</artifactId>
3629
<version>1.0.0-SNAPSHOT</version>
3730
</dependency>
3831

0 commit comments

Comments
 (0)