GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Spring Boot 2.0 新特性(二):新增事件ApplicationStartedEvent · fullsing/SpringBoot-Learning@c297ada

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Chapter1-2-1
    • pom.xml
    • src/main
      • java/com/didispace
        • Application.java
        • ApplicationEnvironmentPreparedEventListener.java
        • ApplicationFailedEventListener.java
        • ApplicationPreparedEventListener.java
        • ApplicationReadyEventListener.java
        • ApplicationStartedEventListener.java
        • ApplicationStartingEventListener.java
      • resources
        • META-INF
          • spring.factories
        • application.properties
  • README.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Chapter1-2-1/pom.xml‎

Copy file name to clipboard
+54Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.didispace</groupId>
7+
<artifactId>Chapter1-2-1</artifactId>
8+
<version>1.0.0</version>
9+
<packaging>jar</packaging>
10+
11+
<name>Chapter1-2-1</name>
12+
<description>Spring Boot 2.0 features : Application Events and Listeners</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>2.0.0.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<java.version>1.8</java.version>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-web</artifactId>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-test</artifactId>
35+
<scope>test</scope>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.projectlombok</groupId>
40+
<artifactId>lombok</artifactId>
41+
<scope>provided</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-maven-plugin</artifactId>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
54+
</project>
Collapse file

‎Chapter1-2-1/src/main/java/com/didispace/Application.java‎

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.didispace;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.boot.CommandLineRunner;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
import org.springframework.context.annotation.Bean;
8+
9+
@Slf4j
10+
@SpringBootApplication
11+
public class Application {
12+
13+
public static void main(String[] args) {
14+
SpringApplication.run(Application.class, args);
15+
}
16+
17+
@Bean
18+
public DataLoader dataLoader() {
19+
return new DataLoader();
20+
}
21+
22+
@Slf4j
23+
static class DataLoader implements CommandLineRunner {
24+
25+
@Override
26+
public void run(String... strings) throws Exception {
27+
log.info("Loading data...");
28+
}
29+
}
30+
31+
}
Collapse file

‎Chapter1-2-1/src/main/java/com/didispace/ApplicationEnvironmentPreparedEventListener.java‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.didispace;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
5+
import org.springframework.context.ApplicationListener;
6+
7+
@Slf4j
8+
public class ApplicationEnvironmentPreparedEventListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent> {
9+
10+
@Override
11+
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
12+
log.info("......ApplicationEnvironmentPreparedEvent......");
13+
}
14+
15+
}
Collapse file

‎Chapter1-2-1/src/main/java/com/didispace/ApplicationFailedEventListener.java‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.didispace;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.boot.context.event.ApplicationFailedEvent;
5+
import org.springframework.context.ApplicationListener;
6+
7+
@Slf4j
8+
public class ApplicationFailedEventListener implements ApplicationListener<ApplicationFailedEvent> {
9+
10+
@Override
11+
public void onApplicationEvent(ApplicationFailedEvent event) {
12+
log.info("......ApplicationFailedEvent......");
13+
}
14+
15+
}
Collapse file

‎Chapter1-2-1/src/main/java/com/didispace/ApplicationPreparedEventListener.java‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.didispace;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.boot.context.event.ApplicationPreparedEvent;
5+
import org.springframework.context.ApplicationListener;
6+
7+
@Slf4j
8+
public class ApplicationPreparedEventListener implements ApplicationListener<ApplicationPreparedEvent> {
9+
10+
@Override
11+
public void onApplicationEvent(ApplicationPreparedEvent event) {
12+
log.info("......ApplicationPreparedEvent......");
13+
}
14+
15+
}
Collapse file

‎Chapter1-2-1/src/main/java/com/didispace/ApplicationReadyEventListener.java‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.didispace;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.boot.context.event.ApplicationReadyEvent;
5+
import org.springframework.context.ApplicationListener;
6+
7+
@Slf4j
8+
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {
9+
10+
@Override
11+
public void onApplicationEvent(ApplicationReadyEvent event) {
12+
log.info("......ApplicationReadyEvent......");
13+
}
14+
15+
}
Collapse file

‎Chapter1-2-1/src/main/java/com/didispace/ApplicationStartedEventListener.java‎

Copy file name to clipboard
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.didispace;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.context.event.ApplicationStartedEvent;
6+
import org.springframework.context.ApplicationListener;
7+
8+
@Slf4j
9+
public class ApplicationStartedEventListener implements ApplicationListener<ApplicationStartedEvent> {
10+
11+
@Override
12+
public void onApplicationEvent(ApplicationStartedEvent event) {
13+
log.info("......ApplicationStartedEvent......");
14+
}
15+
16+
}
Collapse file

‎Chapter1-2-1/src/main/java/com/didispace/ApplicationStartingEventListener.java‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.didispace;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.boot.context.event.ApplicationStartingEvent;
5+
import org.springframework.context.ApplicationListener;
6+
7+
@Slf4j
8+
public class ApplicationStartingEventListener implements ApplicationListener<ApplicationStartingEvent> {
9+
10+
@Override
11+
public void onApplicationEvent(ApplicationStartingEvent event) {
12+
log.info("......ApplicationStartingEvent......");
13+
}
14+
15+
}
Collapse file

‎Chapter1-2-1/src/main/resources/META-INF/spring.factories‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
org.springframework.context.ApplicationListener=com.didispace.ApplicationEnvironmentPreparedEventListener,\
2+
com.didispace.ApplicationFailedEventListener,\
3+
com.didispace.ApplicationPreparedEventListener,\
4+
com.didispace.ApplicationReadyEventListener,\
5+
com.didispace.ApplicationStartedEventListener,\
6+
com.didispace.ApplicationStartingEventListener
Collapse file

‎Chapter1-2-1/src/main/resources/application.properties‎

Copy file name to clipboardExpand all lines: Chapter1-2-1/src/main/resources/application.properties
Whitespace-only changes.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.