* zero-restructure:
Package restructure
Further maven module restructure
Polish and fix sonar warnings
Minor pom tweaks
Add structure 101 project
Remove servet/filter class tangle
Restructure autoconfigure project
Remove tangles from core + minor polish
Restructure packages
Minor change to code formatting
Move @AssertMissingBean to tests
Polish Javadoc
Restructure 'bootstrap' to use 'zero'
Source formatting and clean-up
Restructure projects layout
Minimum fuss for getting applications up and running in production,
and in other environments. There is a strong emphasis on implementing
@ -23,8 +23,8 @@ RESTful web services but many features are more generic than that.
@@ -23,8 +23,8 @@ RESTful web services but many features are more generic than that.
For a quick introduction and to get started quickly with a new
project, carry on reading. For more in depth coverage of the features
@ -47,18 +47,18 @@ If you are using Maven create a really simple `pom.xml` with 2 dependencies:
@@ -47,18 +47,18 @@ If you are using Maven create a really simple `pom.xml` with 2 dependencies:
@ -72,7 +72,7 @@ If you are using Maven create a really simple `pom.xml` with 2 dependencies:
@@ -72,7 +72,7 @@ If you are using Maven create a really simple `pom.xml` with 2 dependencies:
</project>
If you like Gradle, that's fine, and you will know what to do with
those dependencies. The first dependency adds Spring Bootstrap auto
those dependencies. The first dependency adds Spring Zero auto
configuration and the Jetty container to your application, and the
second one adds some more opinionated stuff like the default
management endpoints. If you prefer Tomcat you can just add the
@ -89,7 +89,7 @@ Then in another terminal
@@ -89,7 +89,7 @@ Then in another terminal
`/health` is the default location for the health endpoint - it tells
you if the application is running and healthy. `/metrics` is the default
location for the metrics endpoint - it gives you basic counts and
@ -121,14 +121,14 @@ endpoint. An endpoint can be implemented as a Spring MVC
@@ -121,14 +121,14 @@ endpoint. An endpoint can be implemented as a Spring MVC
You can launch that straight away using the Spring Bootstrap CLI
You can launch that straight away using the Spring Zero CLI
(without the `@EnableAutoConfiguration` and even without the import
statements that your IDE will add if you are using one), or you can
use the main method to launch it from your project jar. Just add a
@ -155,7 +155,7 @@ which are more convenient at development time. Here are a few:
@@ -155,7 +155,7 @@ which are more convenient at development time. Here are a few:
1. Use the Maven exec plugin, e.g.
$ mvn exec:java
2. Run directly in your IDE, e.g. Eclipse or IDEA let you right click
on a class and run it.
@ -167,7 +167,7 @@ on a class and run it.
@@ -167,7 +167,7 @@ on a class and run it.
## Externalizing configuration
Spring Bootstrap likes you to externalize your configuration so you
Spring Zero likes you to externalize your configuration so you
can work with the same application code in different environments. To
get started with this you create a file in the root of your classpath
(`src/main/resources` if using Maven) - if you like YAML you can call
@ -187,7 +187,7 @@ or if you like Java `Properties` files, you can call it
@@ -187,7 +187,7 @@ or if you like Java `Properties` files, you can call it
management.port: 9001
logging.file: target/log.out
Those examples are properties that Spring Bootstrap itself binds to
Those examples are properties that Spring Zero itself binds to
out of the box, so if you make that change and run the app again, you
will find the home page on port 9000 instead of 8080:
@ -217,7 +217,7 @@ that is to simply refer to it in an `@Value` annotation, e.g.
@@ -217,7 +217,7 @@ that is to simply refer to it in an `@Value` annotation, e.g.
@Controller
@EnableAutoConfiguration
public class SampleController {
@Value("${service.message:Hello World}")
private String value = "Goodbye Everypone"
@ -226,7 +226,7 @@ that is to simply refer to it in an `@Value` annotation, e.g.
@@ -226,7 +226,7 @@ that is to simply refer to it in an `@Value` annotation, e.g.
@ -251,13 +251,13 @@ automatically in a separate value object. For instance:
@@ -251,13 +251,13 @@ automatically in a separate value object. For instance:
@ -266,10 +266,10 @@ automatically in a separate value object. For instance:
@@ -266,10 +266,10 @@ automatically in a separate value object. For instance:
`@EnableConfigurationProperties(ServiceProperties.class)` you are
saying you want a bean of type `ServiceProperties` and that you want
@ -341,9 +341,9 @@ Then you will be able to inject a `DataSource` into your controller:
@@ -341,9 +341,9 @@ Then you will be able to inject a `DataSource` into your controller:
@ -354,19 +354,19 @@ Then you will be able to inject a `DataSource` into your controller:
@@ -354,19 +354,19 @@ Then you will be able to inject a `DataSource` into your controller:
public Map<String,String> helloWorld() {
return jdbcTemplate.queryForMap("SELECT * FROM MESSAGES WHERE ID=?", 0);
}
...
}
The app will run (going back to the default security configuration):
$ curl user:password@localhost:8080/
{"error":"Internal Server Error", "status":500, "exception":...}
but there's no data in the database yet and the `MESSAGES` table
doesn't even exist, so there's an error. One easy way to fix it is
to provide a `schema.sql` script in the root of the classpath, e.g.
create table MESSAGES (
ID BIGINT NOT NULL PRIMARY KEY,
MESSAGE VARCHAR(255)
@ -377,6 +377,6 @@ Now when you run the app you get a sensible response:
@@ -377,6 +377,6 @@ Now when you run the app you get a sensible response:
$ curl user:password@localhost:8080/
{"ID":0, "MESSAGE":"Hello Phil"}
Obviously, this is only the start, but hopefully you have a good grasp
of the basics and are ready to try it out yourself.
Here are some (most, hopefully all) the features of Spring Bootstrap
Actuator with some commentary to help you start using them. We
Here are some (most, hopefully all) the features of Spring Actuator
with some commentary to help you start using them. We
recommend you first build a project with the Actuator (e.g. the
getting started project from the main README), and then try each
feature in turn there.
@ -63,7 +63,7 @@ configuration and make it only available in certain environments. Any
@@ -63,7 +63,7 @@ configuration and make it only available in certain environments. Any
`@Component` that is marked with `@Profile` will only be loaded in the
profile specified by the latter annotation.
Spring Bootstrap takes it a stage further. If you include in your
Spring Bootstap takes it a stage further. If you include in your
`application.properties` a value for a property named
`spring.active.profiles` then those profiles will be active by
default. E.g.
@ -137,7 +137,7 @@ compiler or IDE.
@@ -137,7 +137,7 @@ compiler or IDE.
YAML is a superset of JSON, and as such is a very convenient format
for specifying hierarchical configuration data, such as that supported
by Spring Bootstrap Actuator. If you prefer to use
by Spring Actuator. If you prefer to use
[YAML](http://yaml.org) instead of Properties files you just need to
include a file called `application.yml` in the root of your classpath
@ -177,7 +177,6 @@ to change the default values imperatively in Java, so get more control
@@ -177,7 +177,6 @@ to change the default values imperatively in Java, so get more control
over the process. You can do this by declaring a bean of the same
type in your application context, e.g. for the server properties:
@AssertMissingBean(ServerProperties.class)
@Bean
public ServerProperties serverProperties() {
ServerProperties server = new ServerProperties();
@ -185,10 +184,6 @@ type in your application context, e.g. for the server properties:
@@ -185,10 +184,6 @@ type in your application context, e.g. for the server properties:
return server;
}
Note the use of `@AssertMissingBean` to guard against any mistakes
where the bean is already defined (and therefore might already have
been bound).
## Server Configuration
The `ServerProperties` are bound to application properties, and
@ -217,7 +212,7 @@ properties in the application properties (see
@@ -217,7 +212,7 @@ properties in the application properties (see
* To enable the Tomcat access log valve (very common in production environments)
More fine-grained control of the Tomcat container is available if you
need it. Instead of letting Spring Bootstrap create the container for
need it. Instead of letting Spring Actuator create the container for
you, just create a bean of type
`TomcatEmbeddedServletContainerFactory` and override one of its
@ -67,9 +67,6 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
@@ -67,9 +67,6 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
@ -140,7 +137,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
@@ -140,7 +137,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
@ -148,7 +146,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
@@ -148,7 +146,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
@ -102,8 +102,8 @@ public class EndpointHandlerAdapter implements HandlerAdapter {
@@ -102,8 +102,8 @@ public class EndpointHandlerAdapter implements HandlerAdapter {
@ -112,7 +112,8 @@ public class EndpointHandlerAdapter implements HandlerAdapter {
@@ -112,7 +112,8 @@ public class EndpointHandlerAdapter implements HandlerAdapter {
@ -179,7 +180,8 @@ public class EndpointHandlerAdapter implements HandlerAdapter {
@@ -179,7 +180,8 @@ public class EndpointHandlerAdapter implements HandlerAdapter {
@ -54,7 +54,8 @@ public class DefaultCounterService implements CounterService {
@@ -54,7 +54,8 @@ public class DefaultCounterService implements CounterService {
@ -43,7 +43,8 @@ public class DefaultGaugeService implements GaugeService {
@@ -43,7 +43,8 @@ public class DefaultGaugeService implements GaugeService {
@ -37,7 +37,8 @@ public class InMemoryMetricRepository implements MetricRepository {
@@ -37,7 +37,8 @@ public class InMemoryMetricRepository implements MetricRepository {
@ -50,7 +51,8 @@ public class InMemoryMetricRepository implements MetricRepository {
@@ -50,7 +51,8 @@ public class InMemoryMetricRepository implements MetricRepository {
@ -60,7 +62,7 @@ public class BasicErrorController implements ErrorController {
@@ -60,7 +62,7 @@ public class BasicErrorController implements ErrorController {
@ -75,9 +77,10 @@ public class BasicErrorController implements ErrorController {
@@ -75,9 +77,10 @@ public class BasicErrorController implements ErrorController {
@ -94,15 +97,17 @@ public class BasicErrorController implements ErrorController {
@@ -94,15 +97,17 @@ public class BasicErrorController implements ErrorController {