整体实现目标:
1) 使用Maven管理Jar包依赖
2) 使用idea开发工具,开发一个使用SpringBoot + SpringMVC + Druid + Mybatis + Bootstrap + Redis 等开源框架
通用的源代码;
本节实现目标:
引入开发所需的jar包,如不完整,在后续章节中补充添加进来
1.1) 引入SpringBoot父类启动版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.7.RELEASE</version>
</parent>
1.2) 配置各个组件的版本属性
<properties>
<druid.version>1.1.9</druid.version>
<mybatis.spring.version>1.3.2</mybatis.spring.version>
<mysql.connector.version>5.1.46</mysql.connector.version>
<spring.orm.version>5.0.7.RELEASE</spring.orm.version>
<hibernate.jpa.version>1.0.0.Final</hibernate.jpa.version>
<log4j.version>1.3.8.RELEASE</log4j.version>
<junit.verion>4.12</junit.verion>
<lombok.version>1.16.20</lombok.version>
</properties>
1.3) 引入Spring的web组件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
1.4) 引入druid数据源管理组件
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
1.5) 引入Spring的jdbc组件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
1.6) 引入Mybatis组件
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
1.7) 引入MySql数据库驱动
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
1.8) 引入ORM框架相关组件
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.orm.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>${hibernate.jpa.version}</version>
</dependency>
1.9) 添加log4j组件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<!-- 排除SpringBoot自带的logback依赖 -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
1.10) 引入敏捷开发组件lombok
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
1.11) 引入Spring的测试组件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.verion}</version>
</dependency>
1.12) 引入spring-boot属性文件组件,配合注解 ConfigurationProperties使用
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
1.13)引入httpClient组件
<!-- 引入httpClient组件 -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpClient.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjon.version}</version>
</dependency>