服务端采用SpringBoot+SpringSecurity来开发,完整搭建过程如下:

创建SpringBoot项目

在IDEA中创建SpringBoot项目,创建完成之后,添加如下依赖:

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.mybatis.spring.boot</groupId>
  4. <artifactId>mybatis-spring-boot-starter</artifactId>
  5. <version>1.3.1</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>org.springframework.boot</groupId>
  9. <artifactId>spring-boot-starter-security</artifactId>
  10. </dependency>
  11. <dependency>
  12. <groupId>org.springframework.boot</groupId>
  13. <artifactId>spring-boot-starter-web</artifactId>
  14. </dependency>
  15. <dependency>
  16. <groupId>com.alibaba</groupId>
  17. <artifactId>druid</artifactId>
  18. <version>1.0.29</version>
  19. </dependency>
  20. <dependency>
  21. <groupId>mysql</groupId>
  22. <artifactId>mysql-connector-java</artifactId>
  23. </dependency>
  24. </dependencies>

这些都是常规的依赖,有SpringBoot、SpringSecurity、Druid数据库连接池,还有数据库驱动。

然后在application.properties中配置数据库,如下:

  1. spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
  2. spring.datasource.url=jdbc:mysql://127.0.0.1:3306/vhr?useUnicode=true&characterEncoding=UTF-8
  3. spring.datasource.username=root
  4. spring.datasource.password=123
  5. server.port=8082

OK,至此,我们的工程就创建好了。