开场白
本文主要简单介绍下 IDEA + Spring boot + Maven 环境下的 本地 jar 包打包及使用姿势。
涉及的工程代码审核后会在文末附上。
我们首先搭一个简单的 Spring boot 工程, 仅有一个方法,给定半径计算圆的面积,代码结构如下:
其中Controller层提供一个接口,调用Service层计算圆的面积并返回:
@RestController
@RequestMapping("/test")
public class TestController {
@Autowired
private TestService testService;
@RequestMapping(path = "/calSquare", method = RequestMethod.GET)
public String calSquare(@RequestParam("radius")Double radius){
Assert.notNull(radius, "radius can not be null");
double square = testService.calSquare(radius);
return "the square is " + String.