JDK:1.8git
使用技術:SpringBoot、Dubbo、Mybatis、Druidgithub
開發工具:Intelj IDEAweb
數據庫:MySQL、Redisredis
項目構建工具:Mavenspring
使用IDEA構建一個主Maven項目,在主Mavne項目中建立兩個子Model(Web項目),分別爲dubbo的提供者端和消費者端,項目結構以下圖:數據庫
在主pom.xml文件中添加springboot的依賴及各個依賴的版本信息。apache
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>www.ypsy.com</groupId> <artifactId>www.icbc.e</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <modules> <module>SanYueIcbcEClient</module> <module>SanYueIcbcEServer</module> </modules> <name>SanYueIcbcE</name> <url>http://maven.apache.org</url> <!--spring-boot父節點依賴,引入這個以後相關的引入就不須要添加version配置,spring-boot會自動選擇最合適的版本--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.4.RELEASE</version> <relativePath/> </parent> <properties> <mybatis-spring-boot.version>1.3.0</mybatis-spring-boot.version> <redis-spring-boot.version>1.4.6.RELEASE</redis-spring-boot.version> <!--druid數據庫鏈接池,監聽數據庫--> <druid.version>1.0.31</druid.version> <dubbo.vaersion>2.5.3</dubbo.vaersion> <zookeeper.version>3.4.10</zookeeper.version> <zkclient.version>0.1</zkclient.version> </properties> <dependencyManagement> <dependencies> <!--springboot相關依賴--> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-spring-boot.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-redis</artifactId> <version>${redis-spring-boot.version}</version> </dependency> <!-- dubbo --> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>${dubbo.vaersion}</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> </exclusions> </dependency> <!--zookeeper--> <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>${zookeeper.version}</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.github.sgroschupf</groupId> <artifactId>zkclient</artifactId> <version>${zkclient.version}</version> </dependency> <!--druid數據庫鏈接池,監聽數據庫--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> </dependencies> </dependencyManagement> <build> <finalName>www.icbc.e</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments> </configuration> </plugin> <!--Spring Boot在編譯的時候,是有默認JDK版本的,如下配置是修改springboot編譯的jdk版本--> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
在提供者端pom.xml添加spring-boot-starter-web依賴:springboot
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
在消費者端pom.xml添加spring-boot-starter-web依賴:mybatis
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>