Standalone Application Using Spring Boot

This commit is contained in:
Umesh Awasthi
2018-11-10 09:09:34 -08:00
parent 080485dacd
commit 46494930fd
11 changed files with 587 additions and 0 deletions

View File

@@ -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();
}
}

View File

@@ -0,0 +1,9 @@
package com.javadevjournal.service;
public class DefaultHelloService implements HelloService {
@Override
public void hello() {
System.out.println("Hello from Hello Service");
}
}

View File

@@ -0,0 +1,6 @@
package com.javadevjournal.service;
public interface HelloService {
void hello();
}

View File

@@ -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() {
}
}