Standalone Application Using Spring Boot
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.javadevjournal;
|
||||
|
||||
import com.javadevjournal.service.DefaultHelloService;
|
||||
import com.javadevjournal.service.HelloService;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringBootStandaloneApplication implements CommandLineRunner {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringBootStandaloneApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HelloService getHelloService(){
|
||||
return new DefaultHelloService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
getHelloService().hello();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.javadevjournal.service;
|
||||
|
||||
public class DefaultHelloService implements HelloService {
|
||||
|
||||
@Override
|
||||
public void hello() {
|
||||
System.out.println("Hello from Hello Service");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.javadevjournal.service;
|
||||
|
||||
public interface HelloService {
|
||||
|
||||
void hello();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.javadevjournal;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SpringBootStandaloneApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user