1、创建springboot项目,过程忽略,详细参考我已写好的springboot环境搭建:https://mp.youkuaiyun.com/postedit/90175419
2、搭建好之后,大致目录如下图
3、pom.xml
<!-- jdbc两种方式 --> <!--<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jdbc</artifactId> </dependency>--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.9</version> </dependency> <!-- 引入前端web,此注解不存在Controller层注解会报一系列错误 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- mybatis --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.1</version> </dependency> <!-- 引入mysql依赖,解决application-dev.xml中驱动driver-class-name无法加载问题 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency>
4、application.yml
spring:
profiles:
active: dev
5、在resources目录下新建application-dev.yml和application-prod.yml配