Skip to content

Commit 59b87e7

Browse files
committed
m
1 parent b90dce5 commit 59b87e7

File tree

16 files changed

+371
-0
lines changed

16 files changed

+371
-0
lines changed

spring-boot-actuator/pom.xml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.neo</groupId>
7+
<artifactId>spring-boot-actuator</artifactId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>spring-boot-actuator</name>
12+
<description>Demo project for Spring Boot</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.5.9.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<java.version>1.8</java.version>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-web</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-actuator</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-test</artifactId>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-devtools</artifactId>
43+
<optional>true</optional>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.springframework.boot</groupId>
51+
<artifactId>spring-boot-maven-plugin</artifactId>
52+
<configuration>
53+
<fork>true</fork>
54+
</configuration>
55+
</plugin>
56+
</plugins>
57+
</build>
58+
59+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.neo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class ActuatorApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(ActuatorApplication.class, args);
11+
}
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.neo.controller;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
@RestController
7+
public class HelloController {
8+
9+
@RequestMapping("/hello")
10+
public String index() {
11+
return "Hello World";
12+
}
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server:
2+
port: 8080
3+
management:
4+
security:
5+
enabled: false #关掉安全认证
6+
port: 8088 #管理端口调整成8088
7+
context-path: /monitor #actuator的访问路径
8+
endpoints:
9+
shutdown:
10+
enabled: true
11+
12+
info:
13+
app:
14+
name: spring-boot-actuator
15+
version: 1.0.0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.neo;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7+
import org.springframework.test.context.junit4.SpringRunner;
8+
9+
@RunWith(SpringRunner.class)
10+
@SpringBootTest
11+
public class ActuatorApplicationTests {
12+
13+
@Test
14+
public void contextLoads() {
15+
System.out.println("hello word");
16+
}
17+
18+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.neo.controller;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.springframework.boot.test.context.SpringBootTest;
7+
import org.springframework.http.MediaType;
8+
import org.springframework.test.context.junit4.SpringRunner;
9+
import org.springframework.test.web.servlet.MockMvc;
10+
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
11+
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
12+
13+
import static org.hamcrest.Matchers.equalTo;
14+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
15+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
16+
17+
@RunWith(SpringRunner.class)
18+
@SpringBootTest
19+
public class HelloTests {
20+
21+
22+
private MockMvc mvc;
23+
24+
@Before
25+
public void setUp() throws Exception {
26+
mvc = MockMvcBuilders.standaloneSetup(new HelloController()).build();
27+
}
28+
29+
@Test
30+
public void getHello() throws Exception {
31+
mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
32+
.andExpect(status().isOk())
33+
.andExpect(content().string(equalTo("Hello World")));
34+
}
35+
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.neo.controller;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.springframework.boot.test.context.SpringBootTest;
7+
import org.springframework.http.MediaType;
8+
import org.springframework.test.context.junit4.SpringRunner;
9+
import org.springframework.test.web.servlet.MockMvc;
10+
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
11+
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
12+
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
13+
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
14+
15+
@RunWith(SpringRunner.class)
16+
@SpringBootTest
17+
public class HelloWorldControlerTests {
18+
19+
private MockMvc mvc;
20+
21+
@Before
22+
public void setUp() throws Exception {
23+
mvc = MockMvcBuilders.standaloneSetup(new HelloController()).build();
24+
}
25+
26+
@Test
27+
public void getHello() throws Exception {
28+
mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
29+
.andExpect(MockMvcResultMatchers.status().isOk())
30+
.andDo(MockMvcResultHandlers.print())
31+
.andReturn();
32+
}
33+
34+
}

spring-boot-admin-simple/pom.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.neo</groupId>
7+
<artifactId>spring-boot-admin-simple</artifactId>
8+
<version>1.0.0.BUILD-SNAPSHOT</version>
9+
10+
<modules>
11+
<module>spring-boot-admin-server</module>
12+
<module>spring-boot-admin-client</module>
13+
</modules>
14+
15+
<packaging>pom</packaging>
16+
<name>Spring boot admin</name>
17+
<description>Demo project for Spring Boot</description>
18+
19+
<parent>
20+
<groupId>org.springframework.boot</groupId>
21+
<artifactId>spring-boot-starter-parent</artifactId>
22+
<version>1.5.9.RELEASE</version>
23+
<relativePath/> <!-- lookup parent from repository -->
24+
</parent>
25+
26+
<properties>
27+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
28+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
29+
<java.version>1.8</java.version>
30+
<spring-cloud.version>Edgware.SR1</spring-cloud.version>
31+
</properties>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter-test</artifactId>
37+
<scope>test</scope>
38+
</dependency>
39+
</dependencies>
40+
41+
<dependencyManagement>
42+
<dependencies>
43+
<dependency>
44+
<groupId>org.springframework.cloud</groupId>
45+
<artifactId>spring-cloud-dependencies</artifactId>
46+
<version>${spring-cloud.version}</version>
47+
<type>pom</type>
48+
<scope>import</scope>
49+
</dependency>
50+
</dependencies>
51+
</dependencyManagement>
52+
53+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>com.neo</groupId>
7+
<artifactId>spring-boot-admin-simple</artifactId>
8+
<version>1.0.0.BUILD-SNAPSHOT</version>
9+
</parent>
10+
<artifactId>spring-boot-admin-client</artifactId>
11+
<packaging>jar</packaging>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>de.codecentric</groupId>
16+
<artifactId>spring-boot-admin-starter-client</artifactId>
17+
<version>1.5.6</version>
18+
</dependency>
19+
</dependencies>
20+
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-maven-plugin</artifactId>
26+
</plugin>
27+
</plugins>
28+
</build>
29+
30+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.neo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class AdminClientApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(AdminClientApplication.class, args);
11+
}
12+
}

0 commit comments

Comments
 (0)