mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '1.5.x'
This commit is contained in:
commit
4604bb7e8a
@ -23,6 +23,13 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -16,14 +16,16 @@
|
||||
|
||||
package sample.actuator.noweb;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class HelloWorldService {
|
||||
|
||||
@Autowired
|
||||
private ServiceProperties configuration;
|
||||
private final ServiceProperties configuration;
|
||||
|
||||
public HelloWorldService(ServiceProperties configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public String getHelloMessage() {
|
||||
return "Hello " + this.configuration.getName();
|
||||
|
@ -18,8 +18,10 @@ package sample.actuator.noweb;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(ServiceProperties.class)
|
||||
public class SampleActuatorNoWebApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -17,12 +17,13 @@
|
||||
package sample.actuator.noweb;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
|
||||
@Component
|
||||
public class ServiceProperties {
|
||||
|
||||
/**
|
||||
* Name of the service.
|
||||
*/
|
||||
private String name = "World";
|
||||
|
||||
public String getName() {
|
||||
|
@ -1 +1 @@
|
||||
health.diskspace.enabled: false
|
||||
health.diskspace.enabled=false
|
@ -45,14 +45,16 @@ dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter-jdbc")
|
||||
compile("org.springframework.boot:spring-boot-starter-security")
|
||||
compile("org.springframework.boot:spring-boot-starter-web")
|
||||
compile("com.h2database:h2")
|
||||
runtime("com.h2database:h2")
|
||||
|
||||
compileOnly('org.springframework.boot:spring-boot-configuration-processor')
|
||||
|
||||
testCompile("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
insecure configurations.runtime
|
||||
}
|
||||
|
||||
// Slightly odd requirement (package a jar file as an insecure app, exlcuding Spring Security)
|
||||
// Slightly odd requirement (package a jar file as an insecure app, excluding Spring Security)
|
||||
// just to demonstrate the "customConfiguration" feature of the Boot gradle plugin.
|
||||
springBoot {
|
||||
customConfiguration = "insecure"
|
||||
|
@ -38,7 +38,15 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -16,14 +16,16 @@
|
||||
|
||||
package sample.actuator;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class HelloWorldService {
|
||||
|
||||
@Autowired
|
||||
private ServiceProperties configuration;
|
||||
private final ServiceProperties configuration;
|
||||
|
||||
public HelloWorldService(ServiceProperties configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public String getHelloMessage() {
|
||||
return "Hello " + this.configuration.getName();
|
||||
|
@ -20,17 +20,25 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SampleActuatorApplication implements HealthIndicator {
|
||||
|
||||
@Override
|
||||
public Health health() {
|
||||
return Health.up().withDetail("hello", "world").build();
|
||||
}
|
||||
@EnableConfigurationProperties(ServiceProperties.class)
|
||||
public class SampleActuatorApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(SampleActuatorApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HealthIndicator helloHealthIndicator() {
|
||||
return new HealthIndicator() {
|
||||
@Override
|
||||
public Health health() {
|
||||
return Health.up().withDetail("hello", "world").build();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import java.util.Map;
|
||||
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Description;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -36,8 +35,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Description("A controller for handling requests for hello messages")
|
||||
public class SampleController {
|
||||
|
||||
@Autowired
|
||||
private HelloWorldService helloWorldService;
|
||||
private final HelloWorldService helloWorldService;
|
||||
|
||||
public SampleController(HelloWorldService helloWorldService) {
|
||||
this.helloWorldService = helloWorldService;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
@ResponseBody
|
||||
|
@ -17,12 +17,13 @@
|
||||
package sample.actuator;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
|
||||
@Component
|
||||
public class ServiceProperties {
|
||||
|
||||
/**
|
||||
* Name of the service.
|
||||
*/
|
||||
private String name = "World";
|
||||
|
||||
public String getName() {
|
||||
|
@ -1,3 +1,5 @@
|
||||
management.security.enabled=false
|
||||
|
||||
#
|
||||
# Infinispan configuration file location.
|
||||
#
|
||||
|
@ -18,23 +18,12 @@
|
||||
<main.basedir>${basedir}/../..</main.basedir>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-couchbase</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
|
@ -16,24 +16,26 @@
|
||||
|
||||
package sample.flyway;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SampleFlywayApplication implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private PersonRepository repository;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
System.err.println(this.repository.findAll());
|
||||
}
|
||||
public class SampleFlywayApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(SampleFlywayApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner runner(final PersonRepository repository) {
|
||||
return new CommandLineRunner() {
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
System.err.println(repository.findAll());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
management.security.enabled=false
|
||||
|
||||
spring.jpa.hibernate.ddl-auto=validate
|
||||
|
||||
spring.h2.console.enabled=true
|
@ -1,2 +1,4 @@
|
||||
# management.context-path=/admin
|
||||
spring.http.converters.preferred-json-mapper: gson
|
||||
management.security.enabled=false
|
||||
|
||||
spring.http.converters.preferred-json-mapper=gson
|
@ -35,8 +35,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@TestPropertySource(properties = { "endpoints.hypermedia.enabled: true",
|
||||
"management.security.enabled: false" })
|
||||
@TestPropertySource(properties = "endpoints.hypermedia.enabled: true")
|
||||
public class SampleHypermediaGsonApplicationTests {
|
||||
|
||||
@Autowired
|
||||
|
@ -16,19 +16,16 @@
|
||||
|
||||
package sample.hypermedia.jpa;
|
||||
|
||||
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.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
@ -37,19 +34,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@DirtiesContext
|
||||
@AutoConfigureMockMvc
|
||||
public class SampleHypermediaJpaApplicationIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void links() throws Exception {
|
||||
this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
|
||||
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed 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 sample.hypermedia.jpa;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@WebAppConfiguration
|
||||
public class SampleHypermediaJpaApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
@ -1 +1,3 @@
|
||||
management.security.enabled=false
|
||||
|
||||
management.context-path=/admin
|
@ -1,2 +1,4 @@
|
||||
# management.context-path=/admin
|
||||
management.security.enabled=false
|
||||
|
||||
endpoints.docs.curies.enabled=true
|
@ -23,14 +23,17 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-integration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-file</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -1,2 +1,2 @@
|
||||
logging.level.org.springframework.integration.file: DEBUG
|
||||
service.greeting: Hello
|
||||
logging.level.org.springframework.integration.file=DEBUG
|
||||
service.greeting=Hello
|
||||
|
@ -29,10 +29,7 @@
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -1,3 +1,5 @@
|
||||
management.security.enabled=false
|
||||
|
||||
spring.jpa.hibernate.ddl-auto=none
|
||||
|
||||
spring.h2.console.enabled=true
|
||||
|
@ -31,6 +31,13 @@
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -17,12 +17,13 @@
|
||||
package sample.metrics.dropwizard;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
|
||||
public class HelloWorldService {
|
||||
public class HelloWorldProperties {
|
||||
|
||||
/**
|
||||
* Name of the service.
|
||||
*/
|
||||
private String name = "World";
|
||||
|
||||
public String getName() {
|
||||
@ -33,8 +34,4 @@ public class HelloWorldService {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getHelloMessage() {
|
||||
return "Hello " + this.name;
|
||||
}
|
||||
|
||||
}
|
@ -19,9 +19,6 @@ package sample.metrics.dropwizard;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.metrics.GaugeService;
|
||||
import org.springframework.context.annotation.Description;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -32,32 +29,21 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Description("A controller for handling requests for hello messages")
|
||||
public class SampleController {
|
||||
|
||||
@Autowired
|
||||
private HelloWorldService helloWorldService;
|
||||
private final HelloWorldProperties helloWorldProperties;
|
||||
|
||||
@Autowired
|
||||
private GaugeService gauges;
|
||||
private final GaugeService gauges;
|
||||
|
||||
public SampleController(HelloWorldProperties helloWorldProperties, GaugeService gauges) {
|
||||
this.helloWorldProperties = helloWorldProperties;
|
||||
this.gauges = gauges;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
@ResponseBody
|
||||
public Map<String, String> hello() {
|
||||
this.gauges.submit("timer.test.value", Math.random() * 1000 + 1000);
|
||||
return Collections.singletonMap("message",
|
||||
this.helloWorldService.getHelloMessage());
|
||||
}
|
||||
|
||||
protected static class Message {
|
||||
|
||||
@NotBlank(message = "Message value cannot be empty")
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
return Collections.singletonMap("message", "Hello " +
|
||||
this.helloWorldProperties.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,8 +18,10 @@ package sample.metrics.dropwizard;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(HelloWorldProperties.class)
|
||||
public class SampleDropwizardMetricsApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -1 +1,3 @@
|
||||
service.name: Phil
|
||||
management.security.enabled=false
|
||||
|
||||
service.name=Phil
|
||||
|
@ -27,6 +27,13 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -17,11 +17,9 @@
|
||||
package sample.metrics.opentsdb;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
|
||||
public class HelloWorldService {
|
||||
public class HelloWorldProperties {
|
||||
|
||||
private String name = "World";
|
||||
|
||||
@ -33,8 +31,4 @@ public class HelloWorldService {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getHelloMessage() {
|
||||
return "Hello " + this.name;
|
||||
}
|
||||
|
||||
}
|
@ -21,7 +21,6 @@ import java.util.Map;
|
||||
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Description;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -31,14 +30,17 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Description("A controller for handling requests for hello messages")
|
||||
public class SampleController {
|
||||
|
||||
@Autowired
|
||||
private HelloWorldService helloWorldService;
|
||||
private final HelloWorldProperties helloWorldProperties;
|
||||
|
||||
public SampleController(HelloWorldProperties helloWorldProperties) {
|
||||
this.helloWorldProperties = helloWorldProperties;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
@ResponseBody
|
||||
public Map<String, String> hello() {
|
||||
return Collections.singletonMap("message",
|
||||
this.helloWorldService.getHelloMessage());
|
||||
return Collections.singletonMap("message", "Hello " +
|
||||
this.helloWorldProperties.getName());
|
||||
}
|
||||
|
||||
protected static class Message {
|
||||
|
@ -20,13 +20,14 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.actuate.autoconfigure.ExportMetricWriter;
|
||||
import org.springframework.boot.actuate.metrics.opentsdb.DefaultOpenTsdbNamingStrategy;
|
||||
import org.springframework.boot.actuate.metrics.opentsdb.OpenTsdbGaugeWriter;
|
||||
import org.springframework.boot.actuate.metrics.opentsdb.OpenTsdbNamingStrategy;
|
||||
import org.springframework.boot.actuate.metrics.writer.GaugeWriter;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(HelloWorldProperties.class)
|
||||
public class SampleOpenTsdbExportApplication {
|
||||
|
||||
@Bean
|
||||
@ -40,7 +41,7 @@ public class SampleOpenTsdbExportApplication {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("metrics.names")
|
||||
public OpenTsdbNamingStrategy namingStrategy() {
|
||||
public DefaultOpenTsdbNamingStrategy namingStrategy() {
|
||||
return new DefaultOpenTsdbNamingStrategy();
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,4 @@
|
||||
service.name: Phil
|
||||
metrics.names.tags.process: ${spring.application.name:application}:${random.value:0000}
|
||||
management.security.enabled=false
|
||||
|
||||
service.name=Phil
|
||||
metrics.names.tags.process=${spring.application.name:application}:${random.value:0000}
|
@ -31,6 +31,13 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -17,11 +17,9 @@
|
||||
package sample.metrics.redis;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
|
||||
public class HelloWorldService {
|
||||
public class HelloWorldProperties {
|
||||
|
||||
private String name = "World";
|
||||
|
||||
@ -33,8 +31,4 @@ public class HelloWorldService {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getHelloMessage() {
|
||||
return "Hello " + this.name;
|
||||
}
|
||||
|
||||
}
|
@ -31,14 +31,18 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Description("A controller for handling requests for hello messages")
|
||||
public class SampleController {
|
||||
|
||||
private final HelloWorldProperties helloWorldProperties;
|
||||
|
||||
@Autowired
|
||||
private HelloWorldService helloWorldService;
|
||||
public SampleController(HelloWorldProperties helloWorldProperties) {
|
||||
this.helloWorldProperties = helloWorldProperties;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
@ResponseBody
|
||||
public Map<String, String> hello() {
|
||||
return Collections.singletonMap("message",
|
||||
this.helloWorldService.getHelloMessage());
|
||||
return Collections.singletonMap("message", "Hello " +
|
||||
this.helloWorldProperties.getName());
|
||||
}
|
||||
|
||||
protected static class Message {
|
||||
|
@ -24,11 +24,13 @@ import org.springframework.boot.actuate.metrics.export.MetricExportProperties;
|
||||
import org.springframework.boot.actuate.metrics.jmx.JmxMetricWriter;
|
||||
import org.springframework.boot.actuate.metrics.repository.redis.RedisMetricRepository;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.jmx.export.MBeanExporter;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(HelloWorldProperties.class)
|
||||
public class SampleRedisExportApplication {
|
||||
|
||||
@Autowired
|
||||
|
@ -1,7 +1,9 @@
|
||||
service.name: Phil
|
||||
spring.metrics.export.redis.prefix: metrics.sample.${spring.metrics.export.aggregate.prefix}
|
||||
spring.metrics.export.redis.key: keys.metrics.sample
|
||||
spring.metrics.export.aggregate.prefix: ${random.value:0000}.${spring.application.name:application}
|
||||
spring.metrics.export.aggregate.key-pattern: d
|
||||
spring.jmx.default-domain: org.springframework.boot
|
||||
management.security.enabled=false
|
||||
|
||||
service.name=Phil
|
||||
spring.metrics.export.redis.prefix=metrics.sample.${spring.metrics.export.aggregate.prefix}
|
||||
spring.metrics.export.redis.key=keys.metrics.sample
|
||||
spring.metrics.export.aggregate.prefix=${random.value:0000}.${spring.application.name:application}
|
||||
spring.metrics.export.aggregate.key-pattern=d
|
||||
spring.jmx.default-domain=org.springframework.boot
|
||||
spring.data.redis.repositories.enabled=false
|
@ -16,14 +16,16 @@
|
||||
|
||||
package sample.parent;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class HelloWorldService {
|
||||
|
||||
@Autowired
|
||||
private ServiceProperties configuration;
|
||||
private final ServiceProperties configuration;
|
||||
|
||||
public HelloWorldService(ServiceProperties configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public String getHelloMessage(String name) {
|
||||
return this.configuration.getGreeting() + " " + name;
|
||||
|
@ -27,8 +27,12 @@ import org.springframework.util.StreamUtils;
|
||||
@MessageEndpoint
|
||||
public class SampleEndpoint {
|
||||
|
||||
private final HelloWorldService helloWorldService;
|
||||
|
||||
@Autowired
|
||||
private HelloWorldService helloWorldService;
|
||||
public SampleEndpoint(HelloWorldService helloWorldService) {
|
||||
this.helloWorldService = helloWorldService;
|
||||
}
|
||||
|
||||
@ServiceActivator
|
||||
public String hello(File input) throws Exception {
|
||||
|
@ -1 +1 @@
|
||||
service.greeting: Hello
|
||||
service.greeting=Hello
|
@ -24,10 +24,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
|
@ -33,10 +33,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jetty</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -35,10 +35,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jetty</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -23,10 +23,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -33,10 +33,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
Loading…
Reference in New Issue
Block a user