Skip to content

Commit 7e8dd88

Browse files
authored
Merge pull request eugenp#4369 from hemantvsn/hemantvsn_SpringBootNonWebApp_30May18
Added springbootnonwebapp project code
2 parents e3978a5 + 8a96035 commit 7e8dd88

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.baeldung.springbootnonwebapp;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.boot.CommandLineRunner;
6+
import org.springframework.boot.SpringApplication;
7+
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
9+
/**
10+
* 1. Act as main class for spring boot application
11+
* 2. Also implements CommandLineRunner, so that code within run method
12+
* is executed before application startup but after all beans are effectively created
13+
* @author hemant
14+
*
15+
*/
16+
@SpringBootApplication
17+
public class SpringBootConsoleApplication implements CommandLineRunner {
18+
19+
private static Logger LOG = LoggerFactory.getLogger(SpringBootConsoleApplication.class);
20+
21+
public static void main(String[] args) {
22+
LOG.info("STARTING THE APPLICATION");
23+
SpringApplication.run(SpringBootConsoleApplication.class, args);
24+
LOG.info("APPLICATION FINISHED");
25+
}
26+
27+
/**
28+
* This method will be executed after the application context is loaded and
29+
* right before the Spring Application main method is completed.
30+
*/
31+
@Override
32+
public void run(String... args) throws Exception {
33+
LOG.info("EXECUTING : command line runner");
34+
for (int i = 0; i < args.length; ++i) {
35+
LOG.info("args[{}]: {}", i, args[i]);
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)