forked from xkcoding/spring-boot-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
163 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# spring-boot-demo-war | ||
|
||
依赖[spring-boot-demo-parent](../spring-boot-demo-parent)、`spring-boot-starter-tomcat` | ||
|
||
### pom.xml | ||
|
||
```xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>spring-boot-demo-war</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<!-- 打成 war 包修改的第 ① 处 --> | ||
<packaging>war</packaging> | ||
|
||
<name>spring-boot-demo-war</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<parent> | ||
<groupId>com.xkcoding</groupId> | ||
<artifactId>spring-boot-demo-parent</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>../spring-boot-demo-parent/pom.xml</relativePath> | ||
</parent> | ||
|
||
<dependencies> | ||
<!-- 打成 war 包修改的第 ② 处 --> | ||
<!-- 若需要打成 war 包,则需要将 tomcat 引入,scope 设置为 provided --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-tomcat</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>spring-boot-demo-war</finalName> | ||
</build> | ||
|
||
</project> | ||
``` | ||
|
||
### ServletInitializer.java | ||
|
||
```java | ||
/** | ||
* 新建一个 ServletInitializer 类,继承 SpringBootServletInitializer | ||
* <p>打成 war 包修改的第 ③ 处</p> | ||
* @package: com.xkcoding.springbootdemowar | ||
* @description: 新建一个 ServletInitializer 类,继承 SpringBootServletInitializer | ||
* @author: yangkai.shen | ||
* @date: Created in 2017/11/30 下午1:26 | ||
* @copyright: Copyright (c) 2017 | ||
* @version: 0.0.1 | ||
* @modified: yangkai.shen | ||
*/ | ||
public class ServletInitializer extends SpringBootServletInitializer { | ||
|
||
@Override | ||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | ||
return application.sources(SpringBootDemoWarApplication.class); | ||
} | ||
|
||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>spring-boot-demo-war</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<!-- 打成 war 包修改的第 ① 处 --> | ||
<packaging>war</packaging> | ||
|
||
<name>spring-boot-demo-war</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<parent> | ||
<groupId>com.xkcoding</groupId> | ||
<artifactId>spring-boot-demo-parent</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>../spring-boot-demo-parent/pom.xml</relativePath> | ||
</parent> | ||
|
||
<dependencies> | ||
<!-- 打成 war 包修改的第 ② 处 --> | ||
<!-- 若需要打成 war 包,则需要将 tomcat 引入,scope 设置为 provided --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-tomcat</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>spring-boot-demo-war</finalName> | ||
</build> | ||
|
||
</project> |
24 changes: 24 additions & 0 deletions
24
spring-boot-demo-war/src/main/java/com/xkcoding/springbootdemowar/ServletInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.xkcoding.springbootdemowar; | ||
|
||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
import org.springframework.boot.web.support.SpringBootServletInitializer; | ||
|
||
/** | ||
* 新建一个 ServletInitializer 类,继承 SpringBootServletInitializer | ||
* <p>打成 war 包修改的第 ③ 处</p> | ||
* @package: com.xkcoding.springbootdemowar | ||
* @description: 新建一个 ServletInitializer 类,继承 SpringBootServletInitializer | ||
* @author: yangkai.shen | ||
* @date: Created in 2017/11/30 下午1:26 | ||
* @copyright: Copyright (c) 2017 | ||
* @version: 0.0.1 | ||
* @modified: yangkai.shen | ||
*/ | ||
public class ServletInitializer extends SpringBootServletInitializer { | ||
|
||
@Override | ||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | ||
return application.sources(SpringBootDemoWarApplication.class); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...t-demo-war/src/main/java/com/xkcoding/springbootdemowar/SpringBootDemoWarApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.xkcoding.springbootdemowar; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringBootDemoWarApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringBootDemoWarApplication.class, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
server: | ||
port: 8080 | ||
context-path: /demo |
16 changes: 16 additions & 0 deletions
16
...o-war/src/test/java/com/xkcoding/springbootdemowar/SpringBootDemoWarApplicationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.xkcoding.springbootdemowar; | ||
|
||
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 SpringBootDemoWarApplicationTests { | ||
|
||
@Test | ||
public void contextLoads() { | ||
} | ||
|
||
} |