diff --git a/spring-boot-package-war/pom.xml b/spring-boot-package-war/pom.xml
index c54d0da80..667ac7a80 100644
--- a/spring-boot-package-war/pom.xml
+++ b/spring-boot-package-war/pom.xml
@@ -1,67 +1,49 @@
- 4.0.0
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
- com.neo
- spring-boot-package-war
- 0.0.1-SNAPSHOT
- war
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.4.5
+
- spring-boot-package-war
- Demo project for Spring Boot package war
+ com.example
+ hello-world
+ 0.0.2-SNAPSHOT
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.3.6.RELEASE
-
-
+ hello-world
+ A simple Spring Boot app to send hello world message to a user
-
- UTF-8
- 1.7
-
+
+ 1.8
+
-
-
- org.springframework.boot
- spring-boot-starter
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-tomcat
- provided
-
-
- org.springframework.boot
- spring-boot-devtools
- true
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- true
-
-
-
-
-
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
diff --git a/spring-boot-package-war/src/main/java/com/neo/Application.java b/spring-boot-package-war/src/main/java/com/neo/Application.java
deleted file mode 100644
index 6cda50c81..000000000
--- a/spring-boot-package-war/src/main/java/com/neo/Application.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.neo;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-}
diff --git a/spring-boot-package-war/src/main/java/com/neo/HelloWorldApplication.java b/spring-boot-package-war/src/main/java/com/neo/HelloWorldApplication.java
new file mode 100644
index 000000000..478ef2613
--- /dev/null
+++ b/spring-boot-package-war/src/main/java/com/neo/HelloWorldApplication.java
@@ -0,0 +1,13 @@
+package com.example.helloworld;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class HelloWorldApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(HelloWorldApplication.class, args);
+ }
+
+}
diff --git a/spring-boot-package-war/src/main/java/com/neo/ServletInitializer.java b/spring-boot-package-war/src/main/java/com/neo/ServletInitializer.java
deleted file mode 100644
index e57ead010..000000000
--- a/spring-boot-package-war/src/main/java/com/neo/ServletInitializer.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.neo;
-
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.context.web.SpringBootServletInitializer;
-
-/**
- * Created by summer on 2017/5/8.
- */
-public class ServletInitializer extends SpringBootServletInitializer {
- @Override
- protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
- return application.sources(Application.class);
- }
-}
diff --git a/spring-boot-package-war/src/main/java/com/neo/controller/HelloWorldController.java b/spring-boot-package-war/src/main/java/com/neo/controller/HelloWorldController.java
index c231fae49..27a3dcfea 100644
--- a/spring-boot-package-war/src/main/java/com/neo/controller/HelloWorldController.java
+++ b/spring-boot-package-war/src/main/java/com/neo/controller/HelloWorldController.java
@@ -1,13 +1,13 @@
-package com.neo.controller;
+package com.example.helloworld.controller;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController {
-
- @RequestMapping("/hello")
- public String index() {
- return "Hello World xx";
+
+ @GetMapping("/hello")
+ public String sendGreetings() {
+ return "Hello, World!";
}
-}
\ No newline at end of file
+}
diff --git a/spring-boot-package-war/src/test/java/com/neo/ApplicationTests.java b/spring-boot-package-war/src/test/java/com/neo/ApplicationTests.java
deleted file mode 100644
index f35d76c7a..000000000
--- a/spring-boot-package-war/src/test/java/com/neo/ApplicationTests.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.neo;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.SpringApplicationConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringApplicationConfiguration(classes = Application.class)
-public class ApplicationTests {
-
- @Test
- public void contextLoads() {
- }
-
-}
diff --git a/spring-boot-package-war/src/test/java/com/neo/HelloWorldApplicationTests.java b/spring-boot-package-war/src/test/java/com/neo/HelloWorldApplicationTests.java
new file mode 100644
index 000000000..35bba04ef
--- /dev/null
+++ b/spring-boot-package-war/src/test/java/com/neo/HelloWorldApplicationTests.java
@@ -0,0 +1,23 @@
+package com.example.helloworld;
+
+import com.example.helloworld.controller.HelloWorldController;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+
+@SpringBootTest
+class HelloWorldApplicationTests {
+
+ @Autowired
+ private HelloWorldController helloWorldController;
+
+ @Test
+ void contextLoads() {
+ // to ensure that controller is getting created inside the application context
+ assertNotNull(helloWorldController);
+ }
+
+}
diff --git a/spring-boot-package-war/src/test/java/com/neo/controller/HelloTests.java b/spring-boot-package-war/src/test/java/com/neo/controller/HelloTests.java
deleted file mode 100644
index 02133d7ef..000000000
--- a/spring-boot-package-war/src/test/java/com/neo/controller/HelloTests.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.neo.controller;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.SpringApplicationConfiguration;
-import org.springframework.http.MediaType;
-import org.springframework.mock.web.MockServletContext;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringApplicationConfiguration(classes = MockServletContext.class)
-@WebAppConfiguration
-public class HelloTests {
-
-
- private MockMvc mvc;
-
- @Before
- public void setUp() throws Exception {
- mvc = MockMvcBuilders.standaloneSetup(new HelloWorldController()).build();
- }
-
- @Test
- public void getHello() throws Exception {
- mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk())
- .andExpect(content().string(equalTo("Hello World")));
- }
-
-}
\ No newline at end of file
diff --git a/spring-boot-package-war/src/test/java/com/neo/controller/HelloWorldControlerTest.java b/spring-boot-package-war/src/test/java/com/neo/controller/HelloWorldControlerTest.java
new file mode 100644
index 000000000..138d4b23e
--- /dev/null
+++ b/spring-boot-package-war/src/test/java/com/neo/controller/HelloWorldControlerTest.java
@@ -0,0 +1,27 @@
+package com.example.helloworld.controller;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.web.servlet.MockMvc;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@SpringBootTest
+@AutoConfigureMockMvc
+class HelloWorldControllerTest {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @Test
+ public void shouldReturnExpectedMessage() throws Exception {
+
+ mockMvc.perform(get("/hello"))
+ .andExpect(status().isOk())
+ .andExpect(content().string("Hello, World!"));
+ }
+}
diff --git a/spring-boot-package-war/src/test/java/com/neo/controller/HelloWorldControlerTests.java b/spring-boot-package-war/src/test/java/com/neo/controller/HelloWorldControlerTests.java
deleted file mode 100644
index 423d57caa..000000000
--- a/spring-boot-package-war/src/test/java/com/neo/controller/HelloWorldControlerTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.neo.controller;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.SpringApplicationConfiguration;
-import org.springframework.http.MediaType;
-import org.springframework.mock.web.MockServletContext;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
-import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
-import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringApplicationConfiguration(classes = MockServletContext.class)
-@WebAppConfiguration
-public class HelloWorldControlerTests {
-
- private MockMvc mvc;
-
- @Before
- public void setUp() throws Exception {
- mvc = MockMvcBuilders.standaloneSetup(new HelloWorldController()).build();
- }
-
- @Test
- public void getHello() throws Exception {
- mvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON))
- .andExpect(MockMvcResultMatchers.status().isOk())
- .andDo(MockMvcResultHandlers.print())
- .andReturn();
- }
-
-}
\ No newline at end of file
diff --git a/spring-boot-package-war/target/classes/application.properties b/spring-boot-package-war/target/classes/application.properties
new file mode 100644
index 000000000..e69de29bb
diff --git a/spring-boot-package-war/target/classes/com/example/helloworld/HelloWorldApplication.class b/spring-boot-package-war/target/classes/com/example/helloworld/HelloWorldApplication.class
new file mode 100644
index 000000000..3fa6772a7
Binary files /dev/null and b/spring-boot-package-war/target/classes/com/example/helloworld/HelloWorldApplication.class differ
diff --git a/spring-boot-package-war/target/classes/com/example/helloworld/controller/HelloWorldController.class b/spring-boot-package-war/target/classes/com/example/helloworld/controller/HelloWorldController.class
new file mode 100644
index 000000000..630447e9f
Binary files /dev/null and b/spring-boot-package-war/target/classes/com/example/helloworld/controller/HelloWorldController.class differ
diff --git a/spring-boot-package-war/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/spring-boot-package-war/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 000000000..eb86ce5c3
--- /dev/null
+++ b/spring-boot-package-war/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1,2 @@
+com\example\helloworld\controller\HelloWorldController.class
+com\example\helloworld\HelloWorldApplication.class
diff --git a/spring-boot-package-war/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/spring-boot-package-war/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 000000000..3a1e2460d
--- /dev/null
+++ b/spring-boot-package-war/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1,2 @@
+C:\Repo\repo1\spring-boot-examples\spring-boot-package-war\src\main\java\com\neo\HelloWorldApplication.java
+C:\Repo\repo1\spring-boot-examples\spring-boot-package-war\src\main\java\com\neo\controller\HelloWorldController.java
diff --git a/spring-boot-package-war/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/spring-boot-package-war/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
new file mode 100644
index 000000000..396629d23
--- /dev/null
+++ b/spring-boot-package-war/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
@@ -0,0 +1,2 @@
+com\example\helloworld\HelloWorldApplicationTests.class
+com\example\helloworld\controller\HelloWorldControllerTest.class
diff --git a/spring-boot-package-war/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/spring-boot-package-war/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
new file mode 100644
index 000000000..f43b638c6
--- /dev/null
+++ b/spring-boot-package-war/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
@@ -0,0 +1,2 @@
+C:\Repo\repo1\spring-boot-examples\spring-boot-package-war\src\test\java\com\neo\HelloWorldApplicationTests.java
+C:\Repo\repo1\spring-boot-examples\spring-boot-package-war\src\test\java\com\neo\controller\HelloWorldControlerTest.java
diff --git a/spring-boot-package-war/target/surefire-reports/TEST-com.example.helloworld.HelloWorldApplicationTests.xml b/spring-boot-package-war/target/surefire-reports/TEST-com.example.helloworld.HelloWorldApplicationTests.xml
new file mode 100644
index 000000000..8c33ab646
--- /dev/null
+++ b/spring-boot-package-war/target/surefire-reports/TEST-com.example.helloworld.HelloWorldApplicationTests.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-boot-package-war/target/surefire-reports/TEST-com.example.helloworld.controller.HelloWorldControllerTest.xml b/spring-boot-package-war/target/surefire-reports/TEST-com.example.helloworld.controller.HelloWorldControllerTest.xml
new file mode 100644
index 000000000..030e1e84b
--- /dev/null
+++ b/spring-boot-package-war/target/surefire-reports/TEST-com.example.helloworld.controller.HelloWorldControllerTest.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-boot-package-war/target/surefire-reports/com.example.helloworld.HelloWorldApplicationTests.txt b/spring-boot-package-war/target/surefire-reports/com.example.helloworld.HelloWorldApplicationTests.txt
new file mode 100644
index 000000000..2ac8afaf4
--- /dev/null
+++ b/spring-boot-package-war/target/surefire-reports/com.example.helloworld.HelloWorldApplicationTests.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: com.example.helloworld.HelloWorldApplicationTests
+-------------------------------------------------------------------------------
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.333 s - in com.example.helloworld.HelloWorldApplicationTests
diff --git a/spring-boot-package-war/target/surefire-reports/com.example.helloworld.controller.HelloWorldControllerTest.txt b/spring-boot-package-war/target/surefire-reports/com.example.helloworld.controller.HelloWorldControllerTest.txt
new file mode 100644
index 000000000..a9e1a4409
--- /dev/null
+++ b/spring-boot-package-war/target/surefire-reports/com.example.helloworld.controller.HelloWorldControllerTest.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: com.example.helloworld.controller.HelloWorldControllerTest
+-------------------------------------------------------------------------------
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.822 s - in com.example.helloworld.controller.HelloWorldControllerTest
diff --git a/spring-boot-package-war/target/test-classes/com/example/helloworld/HelloWorldApplicationTests.class b/spring-boot-package-war/target/test-classes/com/example/helloworld/HelloWorldApplicationTests.class
new file mode 100644
index 000000000..e15ae296f
Binary files /dev/null and b/spring-boot-package-war/target/test-classes/com/example/helloworld/HelloWorldApplicationTests.class differ
diff --git a/spring-boot-package-war/target/test-classes/com/example/helloworld/controller/HelloWorldControllerTest.class b/spring-boot-package-war/target/test-classes/com/example/helloworld/controller/HelloWorldControllerTest.class
new file mode 100644
index 000000000..5293fed48
Binary files /dev/null and b/spring-boot-package-war/target/test-classes/com/example/helloworld/controller/HelloWorldControllerTest.class differ