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