Merge pull request #9 from eugenp/master

update with origin
This commit is contained in:
Maiklins
2019-09-09 10:57:44 +02:00
committed by GitHub
parent db85c8f275
commit 621491f8db
20076 changed files with 1628788 additions and 0 deletions
@@ -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