diff --git a/TestPlan.md b/TestPlan.md index 123764bb..2d7f573f 100644 --- a/TestPlan.md +++ b/TestPlan.md @@ -429,3 +429,11 @@ Exception in thread "main" java.lang.IllegalStateException CustomEnv: This env is for test plan. SystemPath: ``` + +## Runtime classpath entry +1. Open `27.runtimeClassEntry` in vscode. +2. Press F5 to start. +3. Verify the output in Debug Console should be as following: + ``` + Tomcat started on port(s): 8080 (http) + ``` diff --git a/testprojects/27.runtimeClassEntry/pom.xml b/testprojects/27.runtimeClassEntry/pom.xml new file mode 100644 index 00000000..c723fdf9 --- /dev/null +++ b/testprojects/27.runtimeClassEntry/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + com.github.kdvolder + hello-world-service + 0.0.1-SNAPSHOT + jar + + demo + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 2.0.0.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-devtools + runtime + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + diff --git a/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/Constants.java b/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/Constants.java new file mode 100644 index 00000000..20f31b5e --- /dev/null +++ b/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/Constants.java @@ -0,0 +1,5 @@ +package com.github.kdvolder.helloworldservice; + +public class Constants { + public static final String GREETER_ID = "greeets"; +} \ No newline at end of file diff --git a/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/DemoApplication.java b/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/DemoApplication.java new file mode 100644 index 00000000..d4d22015 --- /dev/null +++ b/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/DemoApplication.java @@ -0,0 +1,52 @@ +package com.github.kdvolder.helloworldservice; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + + +@SpringBootApplication +@RestController +@EnableScheduling +public class DemoApplication { + + public static class Bar { + } + + public static class Foo { + } + + @Autowired(required=false) void foo(@Qualifier("foobar")Foo foo) { + System.out.println("a Foo got injected"); + } + + @Autowired(required=false) void bar(@Qualifier("foobar")Bar bar) { + System.out.println("a Bar got injected"); + } + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } + + @GetMapping(value="/") + public String mainpage() { + return "Hello "+System.getProperty("greeting"); + } + + + @GetMapping(value = "/hello/{name}") + public String getMethodName(@PathVariable String name) { + return "Hello "+name; + } + + + @Bean Foo foobar() { + return new Foo(); + } +} diff --git a/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/Greeter.java b/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/Greeter.java new file mode 100644 index 00000000..b0788c77 --- /dev/null +++ b/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/Greeter.java @@ -0,0 +1,13 @@ +package com.github.kdvolder.helloworldservice; + +import org.springframework.stereotype.Component; + + +@Component +public class Greeter { + + String greeting(String name) { + return "Hello "+name; + } + +} \ No newline at end of file diff --git a/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/MyProperties.java b/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/MyProperties.java new file mode 100644 index 00000000..b6443a7d --- /dev/null +++ b/testprojects/27.runtimeClassEntry/src/main/java/com/github/kdvolder/helloworldservice/MyProperties.java @@ -0,0 +1,26 @@ +package com.github.kdvolder.helloworldservice; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; + +@ConfigurationProperties("my") +public class MyProperties { + + private String hello; + + /** + * @return the hello + */ + @DeprecatedConfigurationProperty(replacement="new.my.hello") + public String getHello() { + return hello; + } + + /** + * @param hello the hello to set + */ + public void setHello(String hello) { + this.hello = hello; + } + +} \ No newline at end of file diff --git a/testprojects/27.runtimeClassEntry/src/main/resources/application.properties b/testprojects/27.runtimeClassEntry/src/main/resources/application.properties new file mode 100644 index 00000000..5c6675f9 --- /dev/null +++ b/testprojects/27.runtimeClassEntry/src/main/resources/application.properties @@ -0,0 +1 @@ +my.hello=Yadaya diff --git a/testprojects/27.runtimeClassEntry/src/main/resources/application.yml b/testprojects/27.runtimeClassEntry/src/main/resources/application.yml new file mode 100644 index 00000000..0e4e2fc0 --- /dev/null +++ b/testprojects/27.runtimeClassEntry/src/main/resources/application.yml @@ -0,0 +1,6 @@ +my: + other: stuff + hello: blah +new: + my: + other: stuff \ No newline at end of file diff --git a/testprojects/27.runtimeClassEntry/src/test/java/com/github/kdvolder/helloworldservice/DemoApplicationTests.java b/testprojects/27.runtimeClassEntry/src/test/java/com/github/kdvolder/helloworldservice/DemoApplicationTests.java new file mode 100644 index 00000000..d7ac76c4 --- /dev/null +++ b/testprojects/27.runtimeClassEntry/src/test/java/com/github/kdvolder/helloworldservice/DemoApplicationTests.java @@ -0,0 +1,16 @@ +package com.github.kdvolder.helloworldservice; + +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 DemoApplicationTests { + + @Test + public void contextLoads() { + } + +}