• 搭建Springboot+mybatis+redis+druid


    准备工作

    JDK:1.8

    使用技术:SpringBoot、Dubbo、Mybatis、Druid

    开发工具:Intelj IDEA

    数据库:MySQL、Redis

    项目构建工具:Maven

    搭建项目骨架

    使用IDEA构建一个主Maven项目,在主Mavne项目中创建两个子Model(Web项目),分别为dubbo的提供者端和消费者端,项目结构如下图:

    在主pom.xml文件中添加springboot的依赖及各个依赖的版本信息。

    <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依赖:

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    搭建消费者端项目

    编写项目启动类

    在消费者端pom.xml添加spring-boot-starter-web依赖:

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    转载于:https://my.oschina.net/u/2289161/blog/1162806

  • 相关阅读:
    企业应用开发中最常用c++库
    ESOURCE_LOCKED
    c++标准之于gcc/vc/boost等实现相当于jsr规范之于sunjdk/ibmjdk/tomcat/weblogic等实现
    c++的各种类型转换方式
    c++的友元类、方法及其益处
    c/c++的typedef/using类型别名
    c++的class声明及相比java的更合理之处
    c++ sleep(windows/linux)
    c++不自动生成相关函数比如赋值、拷贝函数
    c++继承、多态以及与java的行为差异之处
  • 原文地址:https://www.cnblogs.com/twodog/p/12140028.html
Copyright © 2020-2023  润新知