Update samples to use @SpringBootApplication

Update the relevant samples to use the new @SpringBootApplication
annotation.

Closes gh-1842
This commit is contained in:
Phillip Webb
2014-11-06 13:50:45 -08:00
parent 68571ee535
commit d039f43107
43 changed files with 94 additions and 265 deletions

View File

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