BAEL-20881: Move spring-boot-performance into spring-boot-modules
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.lazyinitialization;
|
||||
|
||||
import com.baeldung.lazyinitialization.services.Writer;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
@Bean("writer1")
|
||||
public Writer getWriter1() {
|
||||
return new Writer("Writer 1");
|
||||
}
|
||||
|
||||
@Bean("writer2")
|
||||
public Writer getWriter2() {
|
||||
return new Writer("Writer 2");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ApplicationContext ctx = SpringApplication.run(Application.class, args);
|
||||
System.out.println("Application context initialized!!!");
|
||||
|
||||
Writer writer1 = ctx.getBean("writer1", Writer.class);
|
||||
writer1.write("First message");
|
||||
|
||||
Writer writer2 = ctx.getBean("writer2", Writer.class);
|
||||
writer2.write("Second message");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.lazyinitialization.services;
|
||||
|
||||
public class Writer {
|
||||
|
||||
private final String writerId;
|
||||
|
||||
public Writer(String writerId) {
|
||||
this.writerId = writerId;
|
||||
System.out.println(writerId + " initialized!!!");
|
||||
}
|
||||
|
||||
public void write(String message) {
|
||||
System.out.println(writerId + ": " + message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
spring:
|
||||
main:
|
||||
lazy-initialization: true
|
||||
Reference in New Issue
Block a user