Merge branch 'gh-1842'

This commit is contained in:
Phillip Webb 2014-11-06 22:52:23 -08:00
commit 27cbf45dbe
47 changed files with 179 additions and 269 deletions

View File

@ -0,0 +1,49 @@
/*
* Copyright 2012-2014 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 org.springframework.boot.autoconfigure;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* Indicates a {@link Configuration configuration} class that declares one or more
* {@link Bean @Bean} methods and also triggers {@link EnableAutoConfiguration
* auto-configuration} and {@link ComponentScan component scanning}. This is a convenience
* annotation that is equivalent to declaring {@code @Configuration},
* {@code @EnableAutoConfiguration} and {@code @ComponentScan}.
*
* @author Phillip Webb
* @since 1.2.0
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Configuration
@EnableAutoConfiguration
@ComponentScan
public @interface SpringBootApplication {
}

View File

@ -94,8 +94,9 @@ public class SpringBootCompilerAutoConfiguration extends CompilerAutoConfigurati
private boolean hasEnableAutoConfigureAnnotation(ClassNode classNode) { private boolean hasEnableAutoConfigureAnnotation(ClassNode classNode) {
for (AnnotationNode node : classNode.getAnnotations()) { for (AnnotationNode node : classNode.getAnnotations()) {
if ("EnableAutoConfiguration".equals(node.getClassNode() String name = node.getClassNode().getNameWithoutPackage();
.getNameWithoutPackage())) { if ("EnableAutoConfiguration".equals(name)
|| "SpringBootApplication".equals(name)) {
return true; return true;
} }
} }

View File

@ -1442,7 +1442,7 @@ and http://hibernate.org/orm/documentation/[Hibernate] reference documentation.
Traditionally, JPA '`Entity`' classes are specified in a `persistence.xml` file. With Traditionally, JPA '`Entity`' classes are specified in a `persistence.xml` file. With
Spring Boot this file is not necessary and instead '`Entity Scanning`' is used. By Spring Boot this file is not necessary and instead '`Entity Scanning`' is used. By
default all packages below your main configuration class (the one annotated with default all packages below your main configuration class (the one annotated with
`@EnableAutoConfiguration`) will be searched. `@EnableAutoConfiguration` or `@SpringBootApplication`) will be searched.
Any classes annotated with `@Entity`, `@Embeddable` or `@MappedSuperclass` will be Any classes annotated with `@Entity`, `@Embeddable` or `@MappedSuperclass` will be
considered. A typical entity class would look something like this: considered. A typical entity class would look something like this:
@ -1511,7 +1511,8 @@ Spring Data repositories usually extend from the
{spring-data-commons-javadoc}/repository/Repository.html[`Repository`] or {spring-data-commons-javadoc}/repository/Repository.html[`Repository`] or
{spring-data-commons-javadoc}/repository/CrudRepository.html[`CrudRepository`] interfaces. If you are using {spring-data-commons-javadoc}/repository/CrudRepository.html[`CrudRepository`] interfaces. If you are using
auto-configuration, repositories will be searched from the package containing your auto-configuration, repositories will be searched from the package containing your
main configuration class (the one annotated with `@EnableAutoConfiguration`) down. main configuration class (the one annotated with `@EnableAutoConfiguration` or
`@SpringBootApplication`) down.
Here is a typical Spring Data repository: Here is a typical Spring Data repository:

View File

@ -550,6 +550,36 @@ as `final`, indicating that it cannot be subsequently changed.
[[using-boot-using-springbootapplication-annotation]]
== Using the @SpringBootApplication annotation
Many Spring Boot developers always have their main class annotated with `@Configuration`,
`@EnableAutoConfiguration` and `@ComponentScan`. Since these annotations are so frequently
used together (especially if you follow the <<using-boot-structuring-your-code, best practices>>
above), Spring Boot provides a convenient `@SpringBootApplication` alternative.
The `@SpringBootApplication` annotation is equivalent to using `@Configuration`,
`@EnableAutoConfiguration` and `@ComponentScan` with their default attributes:
[source,java,indent=0]
----
package com.example.myproject;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
----
[[using-boot-running-your-application]] [[using-boot-running-your-application]]
== Running your application == Running your application
One of the biggest advantages of packaging your application as jar and using an embedded One of the biggest advantages of packaging your application as jar and using an embedded

View File

@ -17,15 +17,9 @@
package sample.actuator.log4j; package sample.actuator.log4j;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@EnableConfigurationProperties
@ComponentScan
public class SampleActuatorLog4JApplication { public class SampleActuatorLog4JApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -17,15 +17,9 @@
package sample.actuator.log4j2; package sample.actuator.log4j2;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@EnableConfigurationProperties
@ComponentScan
public class SampleActuatorLog4J2Application { public class SampleActuatorLog4J2Application {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -17,15 +17,9 @@
package sample.actuator; package sample.actuator;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@EnableConfigurationProperties
@ComponentScan
public class SampleActuatorNoWebApplication { public class SampleActuatorNoWebApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -19,15 +19,9 @@ package sample.actuator;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@EnableConfigurationProperties
@ComponentScan
public class SampleActuatorApplication implements HealthIndicator { public class SampleActuatorApplication implements HealthIndicator {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -22,13 +22,11 @@ import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor; import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
public class SampleAmqpSimpleApplication { public class SampleAmqpSimpleApplication {
@Autowired @Autowired

View File

@ -19,15 +19,11 @@ package sample.aop;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import sample.aop.service.HelloWorldService; import sample.aop.service.HelloWorldService;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleAopApplication implements CommandLineRunner { public class SampleAopApplication implements CommandLineRunner {
// Simple example shows how an application can spy on itself with AOP // Simple example shows how an application can spy on itself with AOP

View File

@ -27,14 +27,10 @@ import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus; import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
@EnableBatchProcessing @EnableBatchProcessing
public class SampleBatchApplication { public class SampleBatchApplication {

View File

@ -19,13 +19,9 @@ package sample.data.elasticsearch;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleElasticsearchApplication implements CommandLineRunner { public class SampleElasticsearchApplication implements CommandLineRunner {
@Autowired @Autowired

View File

@ -17,9 +17,7 @@
package sample.data.gemfire; package sample.data.gemfire;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.ImportResource;
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
@ -31,10 +29,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* *
* @author John Blum * @author John Blum
*/ */
@Configuration @SpringBootApplication
@ImportResource("/spring-data-gemfire-cache.xml") @ImportResource("/spring-data-gemfire-cache.xml")
@ComponentScan
@EnableAutoConfiguration
@EnableGemfireRepositories @EnableGemfireRepositories
@EnableTransactionManagement @EnableTransactionManagement
public class SampleDataGemFireApplication { public class SampleDataGemFireApplication {

View File

@ -17,13 +17,9 @@
package sample.data.jpa; package sample.data.jpa;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class SampleDataJpaApplication { public class SampleDataJpaApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -19,13 +19,9 @@ package sample.data.mongo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleMongoApplication implements CommandLineRunner { public class SampleMongoApplication implements CommandLineRunner {
@Autowired @Autowired
@ -34,16 +30,16 @@ public class SampleMongoApplication implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
repository.deleteAll(); this.repository.deleteAll();
// save a couple of customers // save a couple of customers
repository.save(new Customer("Alice", "Smith")); this.repository.save(new Customer("Alice", "Smith"));
repository.save(new Customer("Bob", "Smith")); this.repository.save(new Customer("Bob", "Smith"));
// fetch all customers // fetch all customers
System.out.println("Customers found with findAll():"); System.out.println("Customers found with findAll():");
System.out.println("-------------------------------"); System.out.println("-------------------------------");
for (Customer customer : repository.findAll()) { for (Customer customer : this.repository.findAll()) {
System.out.println(customer); System.out.println(customer);
} }
System.out.println(); System.out.println();
@ -51,11 +47,11 @@ public class SampleMongoApplication implements CommandLineRunner {
// fetch an individual customer // fetch an individual customer
System.out.println("Customer found with findByFirstName('Alice'):"); System.out.println("Customer found with findByFirstName('Alice'):");
System.out.println("--------------------------------"); System.out.println("--------------------------------");
System.out.println(repository.findByFirstName("Alice")); System.out.println(this.repository.findByFirstName("Alice"));
System.out.println("Customers found with findByLastName('Smith'):"); System.out.println("Customers found with findByLastName('Smith'):");
System.out.println("--------------------------------"); System.out.println("--------------------------------");
for (Customer customer : repository.findByLastName("Smith")) { for (Customer customer : this.repository.findByLastName("Smith")) {
System.out.println(customer); System.out.println(customer);
} }

View File

@ -19,13 +19,11 @@ package sample.data.redis;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
public class SampleRedisApplication implements CommandLineRunner { public class SampleRedisApplication implements CommandLineRunner {
@Autowired @Autowired
@ -33,9 +31,9 @@ public class SampleRedisApplication implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
ValueOperations<String, String> ops = template.opsForValue(); ValueOperations<String, String> ops = this.template.opsForValue();
String key = "spring.boot.redis.test"; String key = "spring.boot.redis.test";
if (!template.hasKey(key)) { if (!this.template.hasKey(key)) {
ops.set(key, "foo"); ops.set(key, "foo");
} }
System.out.println("Found key " + key + ", value=" + ops.get(key)); System.out.println("Found key " + key + ", value=" + ops.get(key));

View File

@ -17,13 +17,9 @@
package sample.data.jpa; package sample.data.jpa;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class SampleDataRestApplication { public class SampleDataRestApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -19,13 +19,9 @@ package sample.data.solr;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleSolrApplication implements CommandLineRunner { public class SampleSolrApplication implements CommandLineRunner {
@Autowired @Autowired

View File

@ -23,15 +23,11 @@ import javax.persistence.Id;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Configuration @SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class SampleFlywayApplication implements CommandLineRunner { public class SampleFlywayApplication implements CommandLineRunner {
@Autowired @Autowired

View File

@ -23,16 +23,12 @@ import javax.jms.MessageListener;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.listener.DefaultMessageListenerContainer; import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor; import org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleHornetQApplication { public class SampleHornetQApplication {
@Autowired @Autowired

View File

@ -17,16 +17,12 @@
package sample.integration; package sample.integration;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.ImportResource;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@EnableConfigurationProperties(ServiceProperties.class) @EnableConfigurationProperties(ServiceProperties.class)
@ComponentScan
@ImportResource("integration-context.xml") @ImportResource("integration-context.xml")
public class SampleIntegrationApplication { public class SampleIntegrationApplication {

View File

@ -16,13 +16,11 @@
package sample.jersey; package sample.jersey;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan @SpringBootApplication
@EnableAutoConfiguration
public class SampleJerseyApplication extends SpringBootServletInitializer { public class SampleJerseyApplication extends SpringBootServletInitializer {
@Override @Override

View File

@ -20,19 +20,15 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.FilterRegistrationBean; import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import com.sun.jersey.spi.container.servlet.ServletContainer; import com.sun.jersey.spi.container.servlet.ServletContainer;
@Configuration @SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
@Path("/") @Path("/")
public class SampleJersey1Application { public class SampleJersey1Application {

View File

@ -17,13 +17,9 @@
package sample.jetty; package sample.jetty;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleJettyApplication { public class SampleJettyApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -17,13 +17,9 @@
package sample.jetty; package sample.jetty;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleJetty8Application { public class SampleJetty8Application {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -19,14 +19,10 @@ package sample.atomikos;
import java.io.Closeable; import java.io.Closeable;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class SampleAtomikosApplication { public class SampleAtomikosApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -19,14 +19,10 @@ package sample.bitronix;
import java.io.Closeable; import java.io.Closeable;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class SampleBitronixApplication { public class SampleBitronixApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -16,13 +16,9 @@
package sample.jndi; package sample.jndi;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleJndiApplication { public class SampleJndiApplication {
} }

View File

@ -17,13 +17,9 @@
package sample.liquibase; package sample.liquibase;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class SampleLiquibaseApplication { public class SampleLiquibaseApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -17,16 +17,13 @@
package sample.parent; package sample.parent;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource; import org.springframework.context.annotation.ImportResource;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@EnableConfigurationProperties(ServiceProperties.class) @EnableConfigurationProperties(ServiceProperties.class)
@ComponentScan
public class SampleParentContextApplication { public class SampleParentContextApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -19,15 +19,11 @@ package sample.profile;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import sample.profile.service.MessageService; import sample.profile.service.MessageService;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleProfileApplication implements CommandLineRunner { public class SampleProfileApplication implements CommandLineRunner {
// Simple example shows how a command line spring application can execute an // Simple example shows how a command line spring application can execute an

View File

@ -19,15 +19,11 @@ package sample.simple;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import sample.simple.service.HelloWorldService; import sample.simple.service.HelloWorldService;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleSimpleApplication implements CommandLineRunner { public class SampleSimpleApplication implements CommandLineRunner {
// Simple example shows how a command line spring application can execute an // Simple example shows how a command line spring application can execute an

View File

@ -17,15 +17,11 @@
package sample.jsp; package sample.jsp;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleTomcatJspApplication extends SpringBootServletInitializer { public class SampleTomcatJspApplication extends SpringBootServletInitializer {
@Override @Override

View File

@ -23,12 +23,10 @@ import java.io.IOException;
import org.apache.catalina.connector.Connector; import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol; import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
@ -38,9 +36,7 @@ import org.springframework.util.SocketUtils;
* *
* @author Brock Mills * @author Brock Mills
*/ */
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleTomcatTwoConnectorsApplication { public class SampleTomcatTwoConnectorsApplication {
@Bean @Bean

View File

@ -17,15 +17,9 @@
package sample.tomcat; package sample.tomcat;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@ComponentScan @SpringBootApplication
@Configuration
@EnableAutoConfiguration
@EnableConfigurationProperties
public class SampleTomcatSslApplication { public class SampleTomcatSslApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -22,14 +22,10 @@ import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleTomcatApplication { public class SampleTomcatApplication {
private static Log logger = LogFactory.getLog(SampleTomcatApplication.class); private static Log logger = LogFactory.getLog(SampleTomcatApplication.class);

View File

@ -17,15 +17,11 @@
package sample.jsp; package sample.jsp;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleTomcat7JspApplication extends SpringBootServletInitializer { public class SampleTomcat7JspApplication extends SpringBootServletInitializer {
@Override @Override

View File

@ -17,13 +17,9 @@
package sample.traditional; package sample.traditional;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleTraditionalApplication { public class SampleTraditionalApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -25,14 +25,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.ui.velocity.VelocityEngineUtils; import org.springframework.ui.velocity.VelocityEngineUtils;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleVelocityApplication implements CommandLineRunner { public class SampleVelocityApplication implements CommandLineRunner {
@Value("${application.message}") @Value("${application.message}")

View File

@ -17,13 +17,9 @@
package sample.freemarker; package sample.freemarker;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleWebFreeMarkerApplication { public class SampleWebFreeMarkerApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -17,15 +17,11 @@
package sample.ui; package sample.ui;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleGroovyTemplateApplication { public class SampleGroovyTemplateApplication {
@Bean @Bean

View File

@ -17,15 +17,11 @@
package sample.jsp; package sample.jsp;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleWebJspApplication extends SpringBootServletInitializer { public class SampleWebJspApplication extends SpringBootServletInitializer {
@Override @Override

View File

@ -17,13 +17,11 @@
package sample.ui; package sample.ui;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
public class SampleWebStaticApplication extends SpringBootServletInitializer { public class SampleWebStaticApplication extends SpringBootServletInitializer {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -17,15 +17,11 @@
package sample.ui; package sample.ui;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleWebUiApplication { public class SampleWebUiApplication {
@Bean @Bean

View File

@ -17,13 +17,9 @@
package sample.velocity; package sample.velocity;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleWebVelocityApplication { public class SampleWebVelocityApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {

View File

@ -17,11 +17,10 @@
package samples.websocket.config; package samples.websocket.config;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket; import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer; import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
@ -35,8 +34,7 @@ import samples.websocket.echo.EchoService;
import samples.websocket.echo.EchoWebSocketHandler; import samples.websocket.echo.EchoWebSocketHandler;
import samples.websocket.snake.SnakeWebSocketHandler; import samples.websocket.snake.SnakeWebSocketHandler;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@EnableWebSocket @EnableWebSocket
public class SampleWebSocketsApplication extends SpringBootServletInitializer implements public class SampleWebSocketsApplication extends SpringBootServletInitializer implements
WebSocketConfigurer { WebSocketConfigurer {

View File

@ -17,13 +17,9 @@
package sample.ws; package sample.ws;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration @SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
public class SampleWsApplication { public class SampleWsApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {