添加依赖 compile 'io.springfox:springfox-swagger2:2.9.2' compile 'io.springfox:springfox-swagger-ui:2.9.2' 配置 import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration @EnableSwagger2 public class Swagger2Configuration { //api接口包扫描路径 public static final String SWAGGER_SCAN_BASE_PACKAGE = "com.muyao.galaxy"; public static final String VERSION = "1.0.0"; @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select()
import org.springframework.stereotype.*; import org.springframework.beans.factory.annotation.*; @Component public class MyBean { @Value("${name}") private String name; // ... } package com.example; import java.net.InetAddress; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties("acme") public class AcmeProperties { private boolean enabled; private InetAddress remoteAddress; private final Security security = new Security(); public boolean isEnabled() { ... } public void setEnabled(boolean enabled) { ... } public InetAddress getRemoteAddress() { ... } public void setRemoteAddress(InetAddress remoteAddress) {
本项目使用 Gradle。 添加依赖 implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.2' compile group: 'com.baomidou', name: 'mybatis-plus-boot-starter', version: '3.3.1.tmp' 快照需要添加仓库: repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } 配置 MyBatis(MyBatis Plus 也需要的) @SpringBootApplication @MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper") public class Application {
使用 gradle 作为构建工具。 使用 IDEA,选择创建新项目,选择 Spring Initializer ,然后选择依赖和填写项目相关信息即可。 目前用到的依赖: dependencies { implementation 'org.springframework.boot:spring-boot-starter-amqp' implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' implementation 'org.springframework.boot:spring-boot-starter-data-redis' implementation 'org.springframework.boot:spring-boot-starter-mail' implementation 'org.springframework.boot:spring-boot-starter-quartz' implementation 'org.springframework.boot:spring-boot-starter-validation'
添加依赖 点击查询最新版本 compile ‘com.alibaba:druid-spring-boot-starter:1.1.20’ 注意降级了!最新是21,但有bug。 InteIliJ IDEA 2019.3.3 (Ultimate Edition) + jdk 13.0.2 + apache maven 3.6.3 添加配置 spring.datasource.druid.url= # 或spring.datasource.u
Gradle是一个基于Apache Ant和Apache Maven概念的项目自动化构建开源工具。它使用一种基于Groovy的特定领域语言(DS