Commit 22157091 authored by Phillip Webb's avatar Phillip Webb

Merge branch '2.0.x'

parents 5626b7a5 6f0ccc64
......@@ -47,12 +47,14 @@ given the ability to merge pull requests.
None of these is essential for a pull request, but they will all help. They can also be
added after the original pull request but before a merge.
* Use the Spring Framework code format conventions. If you use Eclipse and you follow
the '`Importing into eclipse`' instructions below you should get project specific
formatting automatically. You can also import formatter settings using the
`eclipse-code-formatter.xml` file from the `eclipse` folder. If using IntelliJ IDEA, you
can use the http://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter Plugin]
to import the same file.
* We use the https://github.com/spring-io/spring-javaformat/[Spring JavaFormat] project
to apply code formatting conventions. If you use Eclipse and you follow the '`Importing
into eclipse`' instructions below you should get project specific formatting
automatically. You can also install the https://github.com/spring-io/spring-javaformat/#intellij-idea[Spring JavaFormat IntelliJ Plugin]
or format the code from the Maven build by running
`./mvnw io.spring.javaformat:spring-javaformat-maven-plugin:apply`.
* The build includes checkstyle rules for many of our code conventions. Run
`./mvnw validate` if you want to check you changes are compliant.
* Make sure all new `.java` files to have a simple Javadoc class comment with at least an
`@author` tag identifying you, and preferably at least a paragraph on what the class is
for.
......@@ -80,13 +82,15 @@ should also work without issue.
=== Building from Source
To build the source you will need to install
https://maven.apache.org/run-maven/index.html[Apache Maven] v3.2.3 or above and JDK 1.8.
Spring Boot source can be build from the command line using
http://maven.apache.org/run-maven/index.html[Apache Maven] on JDK 1.8 or above.
We include '`Maven Wrapper`' scripts (`./mvnw` or `mvnw.bat`) that you can run rather
than needing to install Maven locally.
==== Default Build
The project can be built from the root directory using the standard maven command:
The project can be built from the root directory using the standard Maven command:
[indent=0]
----
......@@ -134,9 +138,9 @@ can run this from the top-level directory:
=== Importing into Eclipse
You can import the Spring Boot code into any Eclipse Mars based distribution. The easiest
You can import the Spring Boot code into any Eclipse Oxygen based distribution. The easiest
way to setup a new environment is to use the Eclipse Installer with the provided
`.setup` file.
`.setup` file (in the `/eclipse` folder).
==== Using the Eclipse Installer
......@@ -165,24 +169,21 @@ easier to navigate.
==== Manual Installation with M2Eclipse
If you prefer to install Eclipse yourself we recommend that you use the
If you prefer to install Eclipse yourself you should use the
http://eclipse.org/m2e/[M2Eclipse] eclipse plugin. If you don't already have m2eclipse
installed it is available from the "Eclipse marketplace".
Spring Boot includes project specific source formatting settings, in order to have these
work with m2eclipse, we provide additional Eclipse plugins that you can install:
work with m2eclipse, we provide an additional Eclipse plugin that you can install:
===== Install the m2eclipse-maveneclipse plugin
* Select "`Help`" -> "`Install New Software`".
* Add `https://dl.bintray.com/philwebb/m2eclipse-maveneclipse` as a site.
* Install "Maven Integration for the maven-eclipse-plugin"
===== Install the Spring Formatter plugin
* Select "`Help`" -> "`Install New Software`".
* Add `https://dl.bintray.com/philwebb/spring-eclipse-code-formatter/` as a site.
* Install "Spring Code Formatter"
* Add `https://dl.bintray.com/spring/javaformat-eclipse/` as a site.
* Install "Spring Java Format"
NOTE: These plugins are optional. Projects can be imported without the plugins, your code
NOTE: The plugin is optional. Projects can be imported without the plugins, your code
changes just won't be automatically formatted.
With the requisite eclipse plugins installed you can select
......@@ -191,20 +192,6 @@ need to import the root `spring-boot` pom and the `spring-boot-samples` pom sepa
==== Importing into Eclipse without M2Eclipse
If you prefer not to use m2eclipse you can generate eclipse project metadata using the
following command:
[indent=0]
----
$ ./mvnw eclipse:eclipse
----
The generated eclipse projects can be imported by selecting `import existing projects`
from the `file` menu.
=== Importing into Other IDEs
Maven is well supported by most Java IDEs. Refer to your vendor documentation.
......@@ -212,7 +199,7 @@ Maven is well supported by most Java IDEs. Refer to your vendor documentation.
== Integration Tests
The sample applications are used as integration tests during the build (when you
`mvn install`). Due to the fact that they make use of the `spring-boot-maven-plugin`
`./mvnw install`). Due to the fact that they make use of the `spring-boot-maven-plugin`
they cannot be called directly, and so instead are launched via the
`maven-invoker-plugin`. If you encounter build failures running the integration tests,
check the `build.log` file in the appropriate sample directory.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -63,7 +63,7 @@
<requirement
name="AnyEditTools.feature.group"/>
<requirement
name="org.eclipse.m2e.maveneclipse.feature.feature.group"/>
name="io.spring.javaformat.eclipse.feature.feature.group"/>
<requirement
name="org.eclipse.jst.server_adapters.feature.feature.group"/>
<requirement
......@@ -87,7 +87,7 @@
<repository
url="http://andrei.gmxhome.de/eclipse/"/>
<repository
url="https://dl.bintray.com/philwebb/m2eclipse-maveneclipse"/>
url="https://dl.bintray.com/spring/javaformat-eclipse/"/>
<repository
url="http://download.eclipse.org/egit/github/updates/"/>
<repository
......
......@@ -167,9 +167,10 @@ public class MetricsProperties {
/**
* Whether meter IDs starting with the specified name should publish percentile
* histograms. For monitoring systems that support aggregable percentile calculation
* based on a histogram, this can be set to true. For other systems, this has no effect. The
* longest match wins, the key `all` can also be used to configure all meters.
* histograms. For monitoring systems that support aggregable percentile
* calculation based on a histogram, this can be set to true. For other systems,
* this has no effect. The longest match wins, the key `all` can also be used to
* configure all meters.
*/
private Map<String, Boolean> percentilesHistogram = new LinkedHashMap<>();
......
......@@ -123,7 +123,8 @@ public class EndpointRequestTests {
endpoints.add(mockEndpoint("foo", "foo"));
endpoints.add(mockEndpoint("bar", "bar"));
endpoints.add(mockEndpoint("baz", "baz"));
PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator", () -> endpoints);
PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator",
() -> endpoints);
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo");
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz");
assertMatcher(matcher).matches("/actuator/bar");
......
......@@ -145,7 +145,8 @@ public class EndpointRequestTests {
endpoints.add(mockEndpoint("foo", "foo"));
endpoints.add(mockEndpoint("bar", "bar"));
endpoints.add(mockEndpoint("baz", "baz"));
PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator", () -> endpoints);
PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator",
() -> endpoints);
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo");
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz");
assertMatcher(matcher).matches("/actuator/bar");
......
......@@ -949,6 +949,7 @@ public class KafkaProperties {
"Resource '" + resource + "' must be on a file system", ex);
}
}
}
public static class Jaas {
......
......@@ -244,7 +244,7 @@ public class JpaProperties {
if (ddlAuto != null) {
return ddlAuto;
}
return this.ddlAuto != null ? this.ddlAuto : defaultDdlAuto.get();
return (this.ddlAuto != null ? this.ddlAuto : defaultDdlAuto.get());
}
}
......
......@@ -125,10 +125,9 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
.just("error/" + errorStatus.toString(),
"error/" + SERIES_VIEWS.get(errorStatus.series()), "error/error")
.flatMap((viewName) -> renderErrorView(viewName, responseBody, error))
.switchIfEmpty(
this.errorProperties.getWhitelabel().isEnabled()
? renderDefaultErrorView(responseBody, error)
: Mono.error(getError(request)))
.switchIfEmpty(this.errorProperties.getWhitelabel().isEnabled()
? renderDefaultErrorView(responseBody, error)
: Mono.error(getError(request)))
.next().doOnNext((response) -> logError(request, errorStatus));
}
......
......@@ -72,7 +72,8 @@ public class DispatcherServletAutoConfigurationTests {
// from the default one, we're registering one anyway
@Test
public void registrationOverrideWithDispatcherServletWrongName() {
this.contextRunner.withUserConfiguration(CustomDispatcherServletDifferentName.class)
this.contextRunner
.withUserConfiguration(CustomDispatcherServletDifferentName.class)
.run((context) -> {
ServletRegistrationBean<?> registration = context
.getBean(ServletRegistrationBean.class);
......@@ -89,8 +90,7 @@ public class DispatcherServletAutoConfigurationTests {
.run((context) -> {
ServletRegistrationBean<?> registration = context
.getBean(ServletRegistrationBean.class);
assertThat(registration.getUrlMappings())
.containsExactly("/foo");
assertThat(registration.getUrlMappings()).containsExactly("/foo");
assertThat(registration.getServletName())
.isEqualTo("customDispatcher");
assertThat(context).hasSingleBean(DispatcherServlet.class);
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
......@@ -25,6 +26,7 @@
<aether.version>1.0.2.v20150114</aether.version>
<maven.version>3.1.1</maven.version>
<spock.version>1.0-groovy-2.4</spock.version>
<spring-javaformat.version>0.0.1</spring-javaformat.version>
</properties>
<scm>
<url>http://github.com/spring-projects/spring-boot</url>
......@@ -310,7 +312,12 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.5</version>
<version>8.8</version>
</dependency>
<dependency>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-checkstyle</artifactId>
<version>${spring-javaformat.version}</version>
</dependency>
</dependencies>
</plugin>
......@@ -567,6 +574,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>${spring-javaformat.version}</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
......@@ -575,14 +595,8 @@
<id>checkstyle-validation</id>
<phase>validate</phase>
<configuration>
<skip>${disable.checks}</skip>
<configLocation>src/checkstyle/checkstyle.xml</configLocation>
<suppressionsLocation>src/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
<headerLocation>src/checkstyle/checkstyle-header.txt</headerLocation>
<propertyExpansion>main.basedir=${main.basedir}</propertyExpansion>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failOnViolation>true</failOnViolation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<goals>
......@@ -600,23 +614,6 @@
<parameters>true</parameters>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<useProjectReferences>false</useProjectReferences>
<additionalConfig>
<file>
<name>.settings/org.eclipse.jdt.ui.prefs</name>
<location>${main.basedir}/eclipse/org.eclipse.jdt.ui.prefs</location>
</file>
<file>
<name>.settings/org.eclipse.jdt.core.prefs</name>
<location>${main.basedir}/eclipse/org.eclipse.jdt.core.prefs</location>
</file>
</additionalConfig>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
......
......@@ -249,6 +249,25 @@
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-checkstyle-plugin
</artifactId>
<versionRange>
[3.0.0,)
</versionRange>
<goals>
<goal>check</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
......
......@@ -81,7 +81,7 @@ public class ServletContextInitializerBeans
addAdaptableBeans(beanFactory);
List<ServletContextInitializer> sortedInitializers = this.initializers.values()
.stream()
.flatMap(value -> value.stream()
.flatMap((value) -> value.stream()
.sorted(AnnotationAwareOrderComparator.INSTANCE))
.collect(Collectors.toList());
this.sortedList = Collections.unmodifiableList(sortedInitializers);
......
......@@ -76,10 +76,10 @@ public class SimpleMainTests {
}
private String[] getArgs(String... args) {
List<String> list = new ArrayList<>(Arrays.asList(
"--spring.main.web-application-type=none",
"--spring.main.show-banner=OFF",
"--spring.main.register-shutdownHook=false"));
List<String> list = new ArrayList<>(
Arrays.asList("--spring.main.web-application-type=none",
"--spring.main.show-banner=OFF",
"--spring.main.register-shutdownHook=false"));
if (args.length > 0) {
list.add("--spring.main.sources="
+ StringUtils.arrayToCommaDelimitedString(args));
......
......@@ -70,8 +70,7 @@ public class BindConverterTests {
@Test
public void createWhenPropertyEditorInitializerIsNullShouldCreate() {
new BindConverter(
ApplicationConversionService.getSharedInstance(), null);
new BindConverter(ApplicationConversionService.getSharedInstance(), null);
}
@Test
......
......@@ -15,6 +15,7 @@
<properties>
<main.basedir>${basedir}/..</main.basedir>
<java.version>1.8</java.version>
<spring-javaformat.version>0.0.1</spring-javaformat.version>
</properties>
<modules>
<module>spring-boot-sample-ant</module>
......@@ -173,22 +174,49 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>${spring-javaformat.version}</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<useProjectReferences>false</useProjectReferences>
<additionalConfig>
<file>
<name>.settings/org.eclipse.jdt.ui.prefs</name>
<location>${main.basedir}/eclipse/org.eclipse.jdt.ui.prefs</location>
</file>
<file>
<name>.settings/org.eclipse.jdt.core.prefs</name>
<location>${main.basedir}/eclipse/org.eclipse.jdt.core.prefs</location>
</file>
</additionalConfig>
</configuration>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.8</version>
</dependency>
<dependency>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-checkstyle</artifactId>
<version>${spring-javaformat.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>checkstyle-validation</id>
<phase>validate</phase>
<configuration>
<configLocation>../spring-boot-parent/src/checkstyle/checkstyle.xml</configLocation>
<suppressionsLocation>../spring-boot-parent/src/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......
......@@ -89,8 +89,8 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
String unknownProperty = "test-does-not-exist";
assertThat(this.environment.containsProperty(unknownProperty)).isFalse();
ResponseEntity<String> entity = new TestRestTemplate()
.withBasicAuth("user", getPassword()).getForEntity(
"http://localhost:" + this.managementPort + "/admin/env/" + unknownProperty,
.withBasicAuth("user", getPassword()).getForEntity("http://localhost:"
+ this.managementPort + "/admin/env/" + unknownProperty,
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
......
......@@ -48,12 +48,12 @@ public class SampleAntApplicationIT {
});
assertThat(jarFiles).hasSize(1);
Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0]
.getName()).directory(target).start();
Process process = new JavaExecutable()
.processBuilder("-jar", jarFiles[0].getName()).directory(target).start();
process.waitFor(5, TimeUnit.MINUTES);
assertThat(process.exitValue()).isEqualTo(0);
String output = FileCopyUtils.copyToString(new InputStreamReader(process
.getInputStream()));
String output = FileCopyUtils
.copyToString(new InputStreamReader(process.getInputStream()));
assertThat(output).contains("Spring Boot Ant Example");
}
......
......@@ -19,9 +19,6 @@ package sample;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author Eddú Meléndez
*/
@RestController
public class MessageController {
......
......@@ -3,4 +3,4 @@ spring.kafka.consumer.group-id=testGroup
spring.kafka.consumer.auto-offset-reset=earliest
spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.JsonDeserializer
spring.kafka.consumer.properties.spring.json.trusted.packages=sample.kafka
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer
\ No newline at end of file
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer
/*
<<<<<<< HEAD:spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java
* Copyright 2012-2017 the original author or authors.
=======
* Copyright 2012-2018 the original author or authors.
>>>>>>> local15x/1.5.x:spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/service/CitySearchCriteria.java
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
......@@ -19,12 +19,11 @@ package sample.secure.webflux;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;
import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
@SpringBootApplication
public class SampleSecureWebFluxApplication {
......@@ -34,7 +33,7 @@ public class SampleSecureWebFluxApplication {
@Bean
public RouterFunction<ServerResponse> monoRouterFunction(EchoHandler echoHandler) {
return route(POST("/echo"), echoHandler::echo);
return RouterFunctions.route(RequestPredicates.POST("/echo"), echoHandler::echo);
}
}
spring.security.user.name=user
spring.security.user.password=password
management.endpoints.web.exposure.include=*
\ No newline at end of file
management.endpoints.web.exposure.include=*
......@@ -101,6 +101,14 @@ public class SampleSecureWebFluxCustomSecurityTests {
.expectStatus().isOk();
}
private String getBasicAuth() {
return new String(Base64.getEncoder().encode(("user:password").getBytes()));
}
private String getBasicAuthForAdmin() {
return new String(Base64.getEncoder().encode(("admin:admin").getBytes()));
}
@Configuration
static class SecurityConfiguration {
......@@ -128,12 +136,4 @@ public class SampleSecureWebFluxCustomSecurityTests {
}
private String getBasicAuth() {
return new String(Base64.getEncoder().encode(("user:password").getBytes()));
}
private String getBasicAuthForAdmin() {
return new String(Base64.getEncoder().encode(("admin:admin").getBytes()));
}
}
spring.security.user.name=user
spring.security.user.password=password
\ No newline at end of file
spring.security.user.password=password
spring.security.user.name=user
spring.security.user.password=password
\ No newline at end of file
spring.security.user.password=password
/*
* Copyright 2012-2018 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.webflux;
import org.springframework.http.MediaType;
......
......@@ -19,12 +19,11 @@ package sample.webflux;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;
import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
@SpringBootApplication
public class SampleWebFluxApplication {
......@@ -34,7 +33,7 @@ public class SampleWebFluxApplication {
@Bean
public RouterFunction<ServerResponse> monoRouterFunction(EchoHandler echoHandler) {
return route(POST("/echo"), echoHandler::echo);
return RouterFunctions.route(RequestPredicates.POST("/echo"), echoHandler::echo);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment