提取公共 API 到单独的模块中
@RequestMapping("/refactor")
public interface IHelloService {
@GetMapping("/hello3")
String hello(@RequestParam(value = "name") String name);
@GetMapping("/hello4")
String hello(@RequestHeader("name") String name, @RequestHeader(value = "age") Integer age);
}
pom.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">
<parent>
<artifactId>spring-cloud-aggregation</artifactId>
<groupId>com.knife.cloud</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hello-service-api</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--<configuration>-->
<!--<!– Bundle all dependencies and project resources. Does not bundle a bootstrap loader–>-->
<!--<layout>NONE</layout>-->
<!--</configuration>-->
<!--</plugin>-->
</plugins>
</build>
</project>
打包之前使用了 spring-boot-maven-plugin 插件,去掉后打包正常