springboot1.5.6整合mybatis、thymeleaf、freemarker、swagger实例
项目代码获取:https://github.com/pysasuke/s...html
@Configuration @EnableSwagger2 //启动swagger2 //请求地址http://localhost:8080/swagger-ui.html public class Swagger2 { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() //须要扫描api的包路径 .apis(RequestHandlerSelectors.basePackage("com.py.springboot.web")) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("Spring Boot中使用Swagger2构建RESTful APIs") .description("这只是一个demo") .contact("PySasuke") .version("1.0") .build(); } }
## 数据源配置 spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf8 spring.datasource.username=root spring.datasource.password=py123456 spring.datasource.driver-class-name=com.mysql.jdbc.Driver ## Mybatis 配置 ##指向实体类包路径 mybatis.typeAliasesPackage=com.py.springboot.entity ##配置为 classpath 路径下 mapper 包下,* 表明会扫描全部 xml 文件 mybatis.mapperLocations=classpath:mapper/*.xml