Console Application with Spring Boot: Difference between revisions
Jump to navigation
Jump to search
Line 19: | Line 19: | ||
=Spring Boot Application Class= | =Spring Boot Application Class= | ||
<syntaxhighlight lang='java'> | |||
import org.springframework.boot.CommandLineRunner; | |||
import org.springframework.boot.SpringApplication; | |||
import org.springframework.boot.autoconfigure.SpringBootApplication; | |||
@SpringBootApplication | |||
public class MyCommandLineApplication implements CommandLineRunner { | |||
public static void main(String[] args) { | |||
SpringApplication.run(MyCommandLineApplication.class, args); | |||
} | |||
@Override | |||
public void run(String... args) throws Exception { | |||
System.out.println("running with " + Arrays.asList(args) + " ..."); | |||
} | |||
} | |||
</syntaxhighlight> |
Revision as of 01:31, 16 October 2018
External
Internal
Overview
Starter Dependencies
dependencies {
implementation('org.springframework.boot:spring-boot-starter')
compileOnly('org.projectlombok:lombok:1.18.2')
}
Spring Boot Application Class
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyCommandLineApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(MyCommandLineApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
System.out.println("running with " + Arrays.asList(args) + " ...");
}
}