User Tools

Site Tools


java:best-practice

BigDecimal转String

不要使用 toString()方法,会转成科学计数法的形式。 要用 toPlainString()

关于swaggerAPI地址规范

/web开头的是 给前端网站使用的
/admin开头的是 给内部用户使用的
/api开头的是暴露给外部用户使用的(卖给客户的api)

然后比如: /web/user (第二层表示 模块名)  

/web/user/updatePassword  第三层表示 真正的功能名字

用构造函数代码@Autowired

  //以前是:
  @Autowired
  private Environment env;
 
  //现在是:
  private final Environment env;
  public UserController(Environment env) {
    this.env = env;
  }
  //优化好的形式:
  @RequiredArgsConstructor
  public class UserController {
    private final Environment env;
  }

F.Y.I.: https://www.cnblogs.com/acm-bingzi/p/springAutowired.html

java/best-practice.txt · Last modified: 2022/06/21 10:29 by morgan0329

Except where otherwise noted, content on this wiki is licensed under the following license: 沪ICP备12046235号-2
Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki