BAEL-20881: Move spring-boot-performance into spring-boot-modules
This commit is contained in:
7
spring-boot-modules/spring-boot-performance/README.md
Normal file
7
spring-boot-modules/spring-boot-performance/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
## Spring Boot Performance
|
||||
|
||||
This module contains articles about Spring Boot performance.
|
||||
|
||||
### Relevant Articles
|
||||
|
||||
- [Lazy Initialization in Spring Boot 2](https://www.baeldung.com/spring-boot-lazy-initialization)
|
||||
45
spring-boot-modules/spring-boot-performance/pom.xml
Normal file
45
spring-boot-modules/spring-boot-performance/pom.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-boot-performance</artifactId>
|
||||
<name>spring-boot-performance</name>
|
||||
<packaging>war</packaging>
|
||||
<description>This is a simple Spring Boot application taking advantage of the latest Spring Boot improvements/features. Current version: 2.2</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>spring-boot-performance</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- The main class to start by executing java -jar -->
|
||||
<start-class>com.baeldung.lazyinitialization.Application</start-class>
|
||||
</properties>
|
||||
</project>
|
||||
@@ -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