forked from yudaocode/SpringBoot-Labs
-
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
YunaiV
committed
Jun 7, 2020
1 parent
f092cfc
commit 4edadf1
Showing
6 changed files
with
116 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?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"> | ||
<parent> | ||
<artifactId>lab-61</artifactId> | ||
<groupId>cn.iocoder.springboot.labs</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>lab-61-springmvc</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<spring.boot.version>2.2.4.RELEASE</spring.boot.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<!-- 引入 SpringMVC 相关依赖,并实现对其的自动配置 --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<!-- 引入 CAT 相关依赖 --> | ||
<dependency> | ||
<groupId>com.dianping.cat</groupId> | ||
<artifactId>cat-client</artifactId> | ||
<version>3.0.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<!-- 引入私服,因为 CAT 依赖并没有发到 Maven 中央仓库 --> | ||
<repositories> | ||
<repository> | ||
<id>central</id> | ||
<name>Maven2 Central Repository</name> | ||
<layout>default</layout> | ||
<url>http://repo1.maven.org/maven2</url> | ||
</repository> | ||
<repository> | ||
<id>unidal.releases</id> | ||
<url>http://unidal.org/nexus/content/repositories/releases/</url> | ||
</repository> | ||
</repositories> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
lab-61/lab-61-springmvc/src/main/java/cn/iocoder/springboot/lab61/catdemo/Application.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,13 @@ | ||
package cn.iocoder.springboot.lab61.catdemo; | ||
|
||
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); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...pringmvc/src/main/java/cn/iocoder/springboot/lab61/catdemo/config/CatFilterConfigure.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 cn.iocoder.springboot.lab61.catdemo.config; | ||
|
||
import com.dianping.cat.servlet.CatFilter; | ||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class CatFilterConfigure { | ||
|
||
@Bean | ||
public FilterRegistrationBean<CatFilter> catFilter() { | ||
// 创建 CatFilter 对象 | ||
CatFilter filter = new CatFilter(); | ||
// 创建 FilterRegistrationBean 对象 | ||
FilterRegistrationBean<CatFilter> registration = new FilterRegistrationBean<>(); | ||
registration.setFilter(filter); | ||
registration.addUrlPatterns("/*"); // 匹配所有 URL | ||
registration.setName("cat-filter"); | ||
registration.setOrder(1); | ||
return registration; | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...pringmvc/src/main/java/cn/iocoder/springboot/lab61/catdemo/controller/DemoController.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 cn.iocoder.springboot.lab61.catdemo.controller; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/demo") | ||
public class DemoController { | ||
|
||
@GetMapping("/hello") | ||
public String hello() { | ||
return "world"; | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
lab-61/lab-61-springmvc/src/main/resources/META-INF/app.properties
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 @@ | ||
app.name=demo-application |
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