**来源于ninjaframework
将@Controller 、 @RequestMapping 、 @GetMapping 、 @PostMapping 等
替换为统一地方管理、配置url
<dependency>
<groupId>com.github.onepiecex</groupId>
<artifactId>router-spring-mvc-spring-boot-starter</artifactId>
<version>1.0</version>
</dependency>
route:
packages: package1,package2
@RestController("/hello2")
public class Hello2Controller {
@GetMapping
public String hello() {
return "hello";
}
@GetMapping("/hello")
public String hello2() {
return "hello";
}
}
@RestController
public class HelloController {
public String hello() {
return "hello";
}
public String hello2() {
return "hello";
}
}
public class MyRoutes implements Routes {
@Override
public void init(Router router) {
router.route("/hello2").GET(HelloController::hello);
router.route("/hello2/hello").POST(HelloController::hello2);
}
}
更多 route 示例 见 MyRoutes.java