Skip to content

Commit 403dda7

Browse files
committed
Remove field inject and circular reference from Data Mongo smoke test
Closes gh-27651
1 parent 3bed23d commit 403dda7

File tree

1 file changed

+26
-28
lines changed
  • spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-mongodb/src/main/java/smoketest/data/mongo

1 file changed

+26
-28
lines changed

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-mongodb/src/main/java/smoketest/data/mongo/SampleMongoApplication.java

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,45 +18,43 @@
1818

1919
import java.util.concurrent.TimeUnit;
2020

21-
import org.springframework.beans.factory.annotation.Autowired;
2221
import org.springframework.boot.CommandLineRunner;
2322
import org.springframework.boot.SpringApplication;
2423
import org.springframework.boot.autoconfigure.SpringBootApplication;
2524
import org.springframework.boot.autoconfigure.mongo.MongoClientSettingsBuilderCustomizer;
2625
import org.springframework.context.annotation.Bean;
2726

2827
@SpringBootApplication
29-
public class SampleMongoApplication implements CommandLineRunner {
28+
public class SampleMongoApplication {
3029

31-
@Autowired
32-
private CustomerRepository repository;
33-
34-
@Override
35-
public void run(String... args) throws Exception {
36-
this.repository.deleteAll();
30+
@Bean
31+
public CommandLineRunner exampleRunner(CustomerRepository repository) {
32+
return (args) -> {
33+
repository.deleteAll();
3734

38-
// save a couple of customers
39-
this.repository.save(new Customer("Alice", "Smith"));
40-
this.repository.save(new Customer("Bob", "Smith"));
35+
// save a couple of customers
36+
repository.save(new Customer("Alice", "Smith"));
37+
repository.save(new Customer("Bob", "Smith"));
4138

42-
// fetch all customers
43-
System.out.println("Customers found with findAll():");
44-
System.out.println("-------------------------------");
45-
for (Customer customer : this.repository.findAll()) {
46-
System.out.println(customer);
47-
}
48-
System.out.println();
39+
// fetch all customers
40+
System.out.println("Customers found with findAll():");
41+
System.out.println("-------------------------------");
42+
for (Customer customer : repository.findAll()) {
43+
System.out.println(customer);
44+
}
45+
System.out.println();
4946

50-
// fetch an individual customer
51-
System.out.println("Customer found with findByFirstName('Alice'):");
52-
System.out.println("--------------------------------");
53-
System.out.println(this.repository.findByFirstName("Alice"));
47+
// fetch an individual customer
48+
System.out.println("Customer found with findByFirstName('Alice'):");
49+
System.out.println("--------------------------------");
50+
System.out.println(repository.findByFirstName("Alice"));
5451

55-
System.out.println("Customers found with findByLastName('Smith'):");
56-
System.out.println("--------------------------------");
57-
for (Customer customer : this.repository.findByLastName("Smith")) {
58-
System.out.println(customer);
59-
}
52+
System.out.println("Customers found with findByLastName('Smith'):");
53+
System.out.println("--------------------------------");
54+
for (Customer customer : repository.findByLastName("Smith")) {
55+
System.out.println(customer);
56+
}
57+
};
6058
}
6159

6260
@Bean

0 commit comments

Comments
 (0)