Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
c903ff46
Commit
c903ff46
authored
Dec 30, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish samples
parent
a19a2806
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
149 additions
and
105 deletions
+149
-105
pom.xml
...ng-boot-samples/spring-boot-sample-actuator-noweb/pom.xml
+7
-0
HelloWorldService.java
...rc/main/java/sample/actuator/noweb/HelloWorldService.java
+5
-3
SampleActuatorNoWebApplication.java
...sample/actuator/noweb/SampleActuatorNoWebApplication.java
+2
-0
ServiceProperties.java
...rc/main/java/sample/actuator/noweb/ServiceProperties.java
+3
-2
application.properties
...ple-actuator-ui/src/main/resources/application.properties
+1
-1
build.gradle
spring-boot-samples/spring-boot-sample-actuator/build.gradle
+4
-2
pom.xml
spring-boot-samples/spring-boot-sample-actuator/pom.xml
+9
-0
HelloWorldService.java
...ator/src/main/java/sample/actuator/HelloWorldService.java
+5
-3
SampleActuatorApplication.java
.../main/java/sample/actuator/SampleActuatorApplication.java
+14
-6
SampleController.java
...uator/src/main/java/sample/actuator/SampleController.java
+5
-3
ServiceProperties.java
...ator/src/main/java/sample/actuator/ServiceProperties.java
+3
-2
SampleFlywayApplication.java
.../src/main/java/sample/flyway/SampleFlywayApplication.java
+12
-10
SampleHypermediaJpaApplicationIntegrationTests.java
...a/jpa/SampleHypermediaJpaApplicationIntegrationTests.java
+2
-12
pom.xml
spring-boot-samples/spring-boot-sample-integration/pom.xml
+7
-0
application.properties
...ple-integration/src/main/resources/application.properties
+2
-2
pom.xml
...oot-samples/spring-boot-sample-metrics-dropwizard/pom.xml
+7
-0
HelloWorldProperties.java
.../java/sample/metrics/dropwizard/HelloWorldProperties.java
+4
-7
SampleController.java
...main/java/sample/metrics/dropwizard/SampleController.java
+9
-23
SampleDropwizardMetricsApplication.java
...etrics/dropwizard/SampleDropwizardMetricsApplication.java
+2
-0
pom.xml
...-boot-samples/spring-boot-sample-metrics-opentsdb/pom.xml
+7
-0
HelloWorldProperties.java
...in/java/sample/metrics/opentsdb/HelloWorldProperties.java
+1
-7
SampleController.java
...c/main/java/sample/metrics/opentsdb/SampleController.java
+7
-5
SampleOpenTsdbExportApplication.java
...ple/metrics/opentsdb/SampleOpenTsdbExportApplication.java
+3
-2
pom.xml
spring-boot-samples/spring-boot-sample-metrics-redis/pom.xml
+7
-0
HelloWorldProperties.java
.../main/java/sample/metrics/redis/HelloWorldProperties.java
+1
-7
SampleController.java
.../src/main/java/sample/metrics/redis/SampleController.java
+7
-3
SampleRedisExportApplication.java
...va/sample/metrics/redis/SampleRedisExportApplication.java
+2
-0
HelloWorldService.java
...ontext/src/main/java/sample/parent/HelloWorldService.java
+5
-3
SampleEndpoint.java
...t-context/src/main/java/sample/parent/SampleEndpoint.java
+5
-1
application.properties
...-parent-context/src/main/resources/application.properties
+1
-1
No files found.
spring-boot-samples/spring-boot-sample-actuator-noweb/pom.xml
View file @
c903ff46
...
...
@@ -27,6 +27,13 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-remote-shell
</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>
...
...
spring-boot-samples/spring-boot-sample-actuator-noweb/src/main/java/sample/actuator/noweb/HelloWorldService.java
View file @
c903ff46
...
...
@@ -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
();
...
...
spring-boot-samples/spring-boot-sample-actuator-noweb/src/main/java/sample/actuator/noweb/SampleActuatorNoWebApplication.java
View file @
c903ff46
...
...
@@ -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
{
...
...
spring-boot-samples/spring-boot-sample-actuator-noweb/src/main/java/sample/actuator/noweb/ServiceProperties.java
View file @
c903ff46
...
...
@@ -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
()
{
...
...
spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/application.properties
View file @
c903ff46
health.diskspace.enabled
:
false
\ No newline at end of file
health.diskspace.enabled
=
false
\ No newline at end of file
spring-boot-samples/spring-boot-sample-actuator/build.gradle
View file @
c903ff46
...
...
@@ -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, ex
lc
uding Spring Security)
// Slightly odd requirement (package a jar file as an insecure app, ex
cl
uding Spring Security)
// just to demonstrate the "customConfiguration" feature of the Boot gradle plugin.
springBoot
{
customConfiguration
=
"insecure"
...
...
spring-boot-samples/spring-boot-sample-actuator/pom.xml
View file @
c903ff46
...
...
@@ -39,10 +39,19 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-remote-shell
</artifactId>
</dependency>
<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>
...
...
spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/HelloWorldService.java
View file @
c903ff46
...
...
@@ -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
();
...
...
spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleActuatorApplication.java
View file @
c903ff46
...
...
@@ -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
();
}
};
}
}
spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleController.java
View file @
c903ff46
...
...
@@ -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
...
...
spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/ServiceProperties.java
View file @
c903ff46
...
...
@@ -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
()
{
...
...
spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/SampleFlywayApplication.java
View file @
c903ff46
...
...
@@ -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
());
}
};
}
}
spring-boot-samples/spring-boot-sample-hypermedia-jpa/src/test/java/sample/hypermedia/jpa/SampleHypermediaJpaApplicationIntegrationTests.java
View file @
c903ff46
...
...
@@ -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
))
...
...
spring-boot-samples/spring-boot-sample-integration/pom.xml
View file @
c903ff46
...
...
@@ -27,6 +27,13 @@
<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>
...
...
spring-boot-samples/spring-boot-sample-integration/src/main/resources/application.properties
View file @
c903ff46
logging.level.org.springframework.integration.file
:
DEBUG
service.greeting
:
Hello
logging.level.org.springframework.integration.file
=
DEBUG
service.greeting
=
Hello
spring-boot-samples/spring-boot-sample-metrics-dropwizard/pom.xml
View file @
c903ff46
...
...
@@ -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>
...
...
spring-boot-samples/spring-boot-sample-metrics-dropwizard/src/main/java/sample/metrics/dropwizard/HelloWorldProperties.java
View file @
c903ff46
...
...
@@ -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
HelloWorld
Service
{
public
class
HelloWorld
Properties
{
/**
* 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
;
}
}
spring-boot-samples/spring-boot-sample-metrics-dropwizard/src/main/java/sample/metrics/dropwizard/SampleController.java
View file @
c903ff46
...
...
@@ -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
;
private
final
GaugeService
gauges
;
@Autowired
private
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
());
}
}
spring-boot-samples/spring-boot-sample-metrics-dropwizard/src/main/java/sample/metrics/dropwizard/SampleDropwizardMetricsApplication.java
View file @
c903ff46
...
...
@@ -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
{
...
...
spring-boot-samples/spring-boot-sample-metrics-opentsdb/pom.xml
View file @
c903ff46
...
...
@@ -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>
...
...
spring-boot-samples/spring-boot-sample-metrics-opentsdb/src/main/java/sample/metrics/opentsdb/HelloWorldProperties.java
View file @
c903ff46
...
...
@@ -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
HelloWorld
Service
{
public
class
HelloWorld
Properties
{
private
String
name
=
"World"
;
...
...
@@ -33,8 +31,4 @@ public class HelloWorldService {
this
.
name
=
name
;
}
public
String
getHelloMessage
()
{
return
"Hello "
+
this
.
name
;
}
}
spring-boot-samples/spring-boot-sample-metrics-opentsdb/src/main/java/sample/metrics/opentsdb/SampleController.java
View file @
c903ff46
...
...
@@ -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
.
helloWorld
Service
.
getHelloMessag
e
());
return
Collections
.
singletonMap
(
"message"
,
"Hello "
+
this
.
helloWorld
Properties
.
getNam
e
());
}
protected
static
class
Message
{
...
...
spring-boot-samples/spring-boot-sample-metrics-opentsdb/src/main/java/sample/metrics/opentsdb/SampleOpenTsdbExportApplication.java
View file @
c903ff46
...
...
@@ -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
Default
OpenTsdbNamingStrategy
namingStrategy
()
{
return
new
DefaultOpenTsdbNamingStrategy
();
}
...
...
spring-boot-samples/spring-boot-sample-metrics-redis/pom.xml
View file @
c903ff46
...
...
@@ -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>
...
...
spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/HelloWorldProperties.java
View file @
c903ff46
...
...
@@ -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
HelloWorld
Service
{
public
class
HelloWorld
Properties
{
private
String
name
=
"World"
;
...
...
@@ -33,8 +31,4 @@ public class HelloWorldService {
this
.
name
=
name
;
}
public
String
getHelloMessage
()
{
return
"Hello "
+
this
.
name
;
}
}
spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleController.java
View file @
c903ff46
...
...
@@ -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
.
helloWorld
Service
.
getHelloMessag
e
());
return
Collections
.
singletonMap
(
"message"
,
"Hello "
+
this
.
helloWorld
Properties
.
getNam
e
());
}
protected
static
class
Message
{
...
...
spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleRedisExportApplication.java
View file @
c903ff46
...
...
@@ -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
...
...
spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/HelloWorldService.java
View file @
c903ff46
...
...
@@ -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
;
...
...
spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleEndpoint.java
View file @
c903ff46
...
...
@@ -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
{
...
...
spring-boot-samples/spring-boot-sample-parent-context/src/main/resources/application.properties
View file @
c903ff46
service.greeting
:
Hello
\ No newline at end of file
service.greeting
=
Hello
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment