zoukankan      html  css  js  c++  java
  • dubbo环境搭建

    dubbo环境主要分为以下几个步骤:

    1.建立项目结构:service-api,service-provider,web(controller接口)

    2.引入jar包(配置pom.xml)

    3.spring配置,springMVC配置,dubbo配置(provider接口提供方:spring-test-provider.xml,web消费方:dubbo-server-consumer.xml),properties文件配置。

    4.zookeeper安装,dubbo基于zookeeper注册、提供、发布服务。

    1.建立项目结构如图所示:

    说明:test-service是接口项目,test-web是webapp项目,建立maven项目。

    2.各个项目的pom.xml配置引入jar包:

    test-service-api的pro.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <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/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>test-service</artifactId>
            <groupId>test</groupId>
            <version>1.0-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>test</groupId>
        <artifactId>test-service-api</artifactId>
    
    
    </project>

    test-service-provider的pom.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <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/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>test-service</artifactId>
            <groupId>test</groupId>
            <version>1.0-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>test</groupId>
        <artifactId>test-service-provider</artifactId>
    
        <dependencies>
            <dependency>
                <groupId>test</groupId>
                <artifactId>test-service-api</artifactId>
                <version>1.0-SNAPSHOT</version>
            </dependency>
        </dependencies>
    
    
    </project>

    test-service的pom.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <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/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>test</artifactId>
            <groupId>test</groupId>
            <version>1.0-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>test</groupId>
        <artifactId>test-service</artifactId>
        <packaging>pom</packaging>
        <modules>
            <module>test-service-api</module>
            <module>test-service-provider</module>
        </modules>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <spring.version>4.3.10.RELEASE</spring.version>
            <mybatis.version>3.3.0</mybatis.version>
            <mybatis-spring.version>1.2.3</mybatis-spring.version>
            <jackson.version>2.6.3</jackson.version>
            <slf4j.version>1.7.13</slf4j.version>
        </properties>
        <dependencies>
    
            <!--Redis封装-->
            <dependency>
                <groupId>com.richgo</groupId>
                <artifactId>richgo-redis-api</artifactId>
                <version>1.0.3-SNAPSHOT</version>
            </dependency>
            <!--公共参数-->
            <dependency>
                <groupId>com.common</groupId>
                <artifactId>common-util</artifactId>
                <version>1.0.19-SNAPSHOT</version>
            </dependency>
            <!--消息队列-->
            <dependency>
                <groupId>com.message</groupId>
                <artifactId>message-service</artifactId>
                <version>1.0.3-SNAPSHOT</version>
            </dependency>
            <!-- hr系统-->
            <dependency>
                <groupId>com.user</groupId>
                <artifactId>user-api</artifactId>
                <version>2.0.6-SNAPSHOT</version>
            </dependency>
            <!-- 统一客户-->
            <dependency>
                <groupId>com.customer</groupId>
                <artifactId>customer-api</artifactId>
                <version>1.2.2-SNAPSHOT</version>
            </dependency>
            <!--  excel解析-->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>3.17</version>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
                <version>3.17</version>
            </dependency>
            <!-- spring 所需包 start -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-oxm</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${spring.version}</version>
            </dependency>
    
            <!-- spring 所需包 end -->
    
    
            <!-- mybatis 框架包 start -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>${mybatis.version}</version>
            </dependency>
            <!-- Mybatis分页插件包 -->
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper</artifactId>
                <version>4.0.3</version>
            </dependency>
            <!-- mybatis 框架包 end -->
    
            <!-- jackson包 start -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <!-- jackson包 start -->
    
            <!-- junit start -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
            </dependency>
            <!-- junit end -->
    
            <!-- slf4j包 start -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
            <!-- slf4j包 end -->
    
            <!-- 自动生成代码 start -->
            <dependency>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-core</artifactId>
                <version>1.3.2</version>
            </dependency>
            <!-- 自动生成代码 end -->
    
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo</artifactId>
                <version>2.5.3</version>
                <exclusions>
                    <exclusion>
                        <artifactId>spring</artifactId>
                        <groupId>org.springframework</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
    
            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>3.4.9</version>
            </dependency>
            <dependency>
                <groupId>com.github.sgroschupf</groupId>
                <artifactId>zkclient</artifactId>
                <version>0.1</version>
            </dependency>
    
            <!--lombok-->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.16.8</version>
            </dependency>
    
            <!--owner-->
            <dependency>
                <groupId>org.aeonbits.owner</groupId>
                <artifactId>owner</artifactId>
                <version>1.0.8</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-codec</groupId>
                        <artifactId>commons-codec</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
        </dependencies>
    </project>

    test-web的pom.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <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/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>test</artifactId>
            <groupId>test</groupId>
            <version>1.0-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>test</groupId>
        <artifactId>test-web</artifactId>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <spring.version>4.2.2.RELEASE</spring.version>
            <spring-webmvc.version>4.2.2.RELEASE</spring-webmvc.version>
            <mysql.version>5.1.37</mysql.version>
            <mybatis.version>3.3.0</mybatis.version>
            <mybatis-spring.version>1.2.3</mybatis-spring.version>
            <jackson.version>2.6.3</jackson.version>
            <commonsio.version>2.4</commonsio.version>
            <json.version>2.4</json.version>
            <slf4j.version>1.7.13</slf4j.version>
            <springfox.swagger.version>2.6.0</springfox.swagger.version>
        </properties>
    
        <dependencies>
    
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>5.2.4.Final</version>
            </dependency>
            <!-- api -->
            <dependency>
                <groupId>com.salesproject</groupId>
                <artifactId>sales-project-api</artifactId>
                <version>1.0.0-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>com.product</groupId>
                <artifactId>product-integrate-api</artifactId>
                <version>1.0.0-SNAPSHOT</version>
            </dependency>
            <!-- 用户 -->
            <dependency>
                <groupId>com.user</groupId>
                <artifactId>user-api</artifactId>
                <version>2.2.0-SNAPSHOT</version>
            </dependency>
            <!-- 公共 -->
            <dependency>
                <groupId>com.common</groupId>
                <artifactId>common-util</artifactId>
                <version>1.0.19-SNAPSHOT</version>
            </dependency>
            <!-- 权限 -->
            <dependency>
                <groupId>com.rbac</groupId>
                <artifactId>rbac-common</artifactId>
                <version>2.0.5-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>com.rbac</groupId>
                <artifactId>rbac-server-api</artifactId>
                <version>2.0.3-SNAPSHOT</version>
            </dependency>
    
            <!-- 产品 -->
            <dependency>
                <groupId>com.product</groupId>
                <artifactId>product-api</artifactId>
                <version>3.0.0-SNAPSHOT</version>
            </dependency>
            <!-- 消息 -->
            <dependency>
                <groupId>com.sms</groupId>
                <artifactId>sms-api</artifactId>
                <version>1.3.1-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>com.richgo</groupId>
                <artifactId>richgo-redis-api</artifactId>
                <version>1.0.3-SNAPSHOT</version>
            </dependency>
    
            <!-- 视频面签 -->
            <dependency>
                <groupId>com.chtwm</groupId>
                <artifactId>videoverify-api</artifactId>
                <version>1.0.0-SNAPSHOT</version>
            </dependency>
    
            <!-- 统一客户-->
            <dependency>
                <groupId>com.customer</groupId>
                <artifactId>customer-api</artifactId>
                <version>2.0.0-SNAPSHOT</version>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/net.sourceforge.javacsv/javacsv -->
            <dependency>
                <groupId>net.sourceforge.javacsv</groupId>
                <artifactId>javacsv</artifactId>
                <version>2.1</version>
            </dependency>
            <!-- jwt -->
            <dependency>
                <groupId>io.jsonwebtoken</groupId>
                <artifactId>jjwt</artifactId>
                <version>0.7.0</version>
            </dependency>
            <!--  excel解析-->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>3.17</version>
            </dependency>
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
                <version>3.17</version>
            </dependency>
            <!-- spring 所需包 start -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${spring.version}</version>
                <type>jar</type>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-oxm</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <!-- spring 所需包 end -->
    
            <!-- spring mvc 所需包 start -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${spring-webmvc.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <!-- spring mvc 所需包 end -->
    
            <!-- spring mvc 文件上传所需包 start -->
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${commonsio.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>1.3.1</version>
            </dependency>
            <!-- spring mvc 文件上传所需包 end -->
    
            <!-- mybatis 框架包 start -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>${mybatis.version}</version>
            </dependency>
            <!-- Mybatis分页插件包 -->
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper</artifactId>
                <version>4.0.3</version>
            </dependency>
            <!-- mybatis 框架包 end -->
    
            <!-- mybatis与spring 整合所需包 start -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis-spring</artifactId>
                <version>${mybatis-spring.version}</version>
            </dependency>
            <!-- mybatis与spring 整合所需包 end -->
    
            <!-- jackson包 start -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <!-- jackson包 start -->
    
            <!-- ehcache缓存 start -->
            <dependency>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
                <version>2.10.0</version>
            </dependency>
            <!-- ehcache缓存 end -->
    
            <!-- junit start -->
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
            </dependency>
            <!-- junit end -->
    
            <!-- javaee api start -->
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>7.0</version>
            </dependency>
            <dependency>
                <groupId>jstl</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency>
            <!-- javaee api end -->
    
            <!-- 数据库连接池druid包 start -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
                <version>1.0.16</version>
            </dependency>
            <!-- 数据库连接池druid包 end -->
    
            <!-- mysql驱动包 start -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>${mysql.version}</version>
            </dependency>
            <!-- mysql驱动包 end -->
    
            <!-- httpclient包 start -->
            <dependency>
                <groupId>commons-httpclient</groupId>
                <artifactId>commons-httpclient</artifactId>
                <version>3.1</version>
            </dependency>
            <!-- httpclient包 end -->
    
            <!-- slf4j包 start -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
            <!-- slf4j包 end -->
    
            <!-- 日期处理包 start -->
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>2.9.1</version>
            </dependency>
            <!-- 日期处理包 end -->
    
            <!-- 读取资源文件包 start -->
            <dependency>
                <groupId>commons-configuration</groupId>
                <artifactId>commons-configuration</artifactId>
                <version>1.10</version>
            </dependency>
            <!-- 读取资源文件包 end -->
    
            <!-- java解析html包 start -->
            <dependency>
                <groupId>org.jsoup</groupId>
                <artifactId>jsoup</artifactId>
                <version>1.8.3</version>
            </dependency>
            <!-- java解析html包 end -->
    
            <!-- mongodb包 start -->
            <dependency>
                <groupId>org.mongodb</groupId>
                <artifactId>mongo-java-driver</artifactId>
                <version>3.1.1</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-mongodb</artifactId>
                <version>1.8.0.RELEASE</version>
            </dependency>
            <!-- mongodb包 end -->
    
            <!-- redis start -->
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-redis</artifactId>
                <version>1.6.0.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>redis.clients</groupId>
                <artifactId>jedis</artifactId>
                <version>2.7.2</version>
            </dependency>
            <!-- redis end -->
    
            <!-- spring session redis start -->
            <dependency>
                <groupId>org.springframework.session</groupId>
                <artifactId>spring-session</artifactId>
                <version>1.0.2.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>com.orange.redis-embedded</groupId>
                <artifactId>embedded-redis</artifactId>
                <version>0.6</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-pool2</artifactId>
                <version>2.4.2</version>
            </dependency>
            <!-- spring session redis end -->
    
            <!-- xml解析 start -->
            <dependency>
                <groupId>dom4j</groupId>
                <artifactId>dom4j</artifactId>
                <version>1.6.1</version>
            </dependency>
            <!-- xml解析 end -->
    
            <!-- solr包start -->
            <dependency>
                <groupId>org.apache.solr</groupId>
                <artifactId>solr-solrj</artifactId>
                <version>5.3.1</version>
            </dependency>
            <!-- solr包end -->
            <!-- apache 工具包 start -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.4</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-math</artifactId>
                <version>2.2</version>
            </dependency>
            <!-- apache 工具包 end -->
    
            <!-- 邮件包 start -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-email</artifactId>
                <version>1.4</version>
            </dependency>
            <!-- 邮件包 end -->
    
            <!-- 文件操作 -->
            <!-- 阿里云包(目前只使用到OSS)start -->
            <dependency>
                <groupId>com.aliyun.openservices</groupId>
                <artifactId>aliyun-openservices</artifactId>
                <version>1.2.3</version>
            </dependency>
            <!-- 阿里云包(目前只使用到OSS) end -->
    
            <!-- ftp上传包 start -->
            <dependency>
                <groupId>commons-net</groupId>
                <artifactId>commons-net</artifactId>
                <version>3.3</version>
                <classifier>ftp</classifier>
            </dependency>
            <!-- ftp上传包 end -->
            <!-- 文件操作 -->
    
            <!-- json start -->
            <!--<dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId>
                <version>${json.version}</version> <classifier>jdk15</classifier> </dependency> -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>1.2.7</version>
            </dependency>
            <!-- json end -->
    
            <!-- rocketmq start -->
            <dependency>
                <groupId>com.alibaba.rocketmq</groupId>
                <artifactId>rocketmq-client</artifactId>
                <version>3.2.6</version>
            </dependency>
            <!-- rocketmq end -->
    
            <!-- Excel start -->
            <dependency>
                <groupId>net.sourceforge.jexcelapi</groupId>
                <artifactId>jxl</artifactId>
                <version>2.6.12</version>
            </dependency>
            <!-- Excel end -->
    
            <!-- 自动生成代码 start -->
            <dependency>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-core</artifactId>
                <version>1.3.2</version>
            </dependency>
            <!-- 自动生成代码 end -->
    
            <dependency>
                <groupId>com.thoughtworks.xstream</groupId>
                <artifactId>xstream</artifactId>
                <version>1.4.7</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo</artifactId>
                <version>2.5.3</version>
                <exclusions>
                    <exclusion>
                        <artifactId>spring</artifactId>
                        <groupId>org.springframework</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>3.4.9</version>
            </dependency>
            <dependency>
                <groupId>com.github.sgroschupf</groupId>
                <artifactId>zkclient</artifactId>
                <version>0.1</version>
            </dependency>
            <!-- swagger-springmvc start -->
            <!-- swagger2核心依赖 -->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>${springfox.swagger.version}</version>
            </dependency>
            <!-- swagger-ui为项目提供api展示及测试的界面 -->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>${springfox.swagger.version}</version>
            </dependency>
            <!--petStore是官方提供的一个代码参考, 可用于后期写文档时进行参考, 可不加 -->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-petstore</artifactId>
                <version>${springfox.swagger.version}</version>
            </dependency>
            <!-- swagger-springmvc end -->
    
            <!--owner-->
            <dependency>
                <groupId>org.aeonbits.owner</groupId>
                <artifactId>owner</artifactId>
                <version>1.0.8</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-codec</groupId>
                        <artifactId>commons-codec</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
            <!-- excel读写工具 -->
            <dependency>
                <groupId>com.xiaoleilu</groupId>
                <artifactId>hutool-all</artifactId>
                <version>3.2.1</version>
            </dependency>
    
    
        </dependencies>
    
    
    </project>

    test的pom.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <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/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>test</groupId>
        <artifactId>test</artifactId>
        <packaging>pom</packaging>
        <version>1.0-SNAPSHOT</version>
        <modules>
            <module>test-service</module>
            <module>test-web</module>
        </modules>
    
    
    </project>

    3.test-service-provider的spring、dubbo配置等,test-web的springMVC、dubbo配置等

    test-service-provider的配置:


    applicationContext.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:task="http://www.springframework.org/schema/task" xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/aop 
                            http://www.springframework.org/schema/aop/spring-aop.xsd
                            http://www.springframework.org/schema/context 
                            http://www.springframework.org/schema/context/spring-context.xsd
                            http://www.springframework.org/schema/tx 
                            http://www.springframework.org/schema/tx/spring-tx.xsd
                            http://www.springframework.org/schema/task
                            http://www.springframework.org/schema/task/spring-task.xsd">
    
        <!--获取数据库主键-->
        <bean class="com.common.listener.MyApplicationContextAware" />
    
        <!-- 引入config.properties文件 -->
        <bean id="placeholderConfig"
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:config.properties</value>
                    <value>classpath:dubbo.properties</value>
                </list>
            </property>
        </bean>
    
        <!--注解控测器:自动扫描(自动注入) -->
        <!--<context:component-scan base-package="com.message"/>-->
        <context:component-scan base-package="com.test">
            <!-- 排除Controller,spring-mvc.xml中扫描,如果不排除会影响事务管理 -->
            <context:exclude-filter type="annotation"
                expression="org.springframework.stereotype.Controller" />
        </context:component-scan>
    
        <!--线程池-->
        <bean id ="taskExecutor"
              class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor" >
            <property name ="corePoolSize" value ="5" />
            <property name ="keepAliveSeconds" value ="300" />
            <property name ="maxPoolSize" value ="10" />
            <property name ="queueCapacity" value ="25" />
        </bean>
    
        <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
            init-method="init" destroy-method="close">
            <property name="url" value="${db.crm.url}" />
            <property name="username" value="${db.crm.user}" />
            <property name="password" value="${db.crm.pwd}" />
    
            <!-- 监控数据库 -->
            <property name="filters">
                <value>stat</value>
            </property>
    
            <!-- 获取连接最大等待时间 -->
            <property name="maxWait">
                <value>${maxWait}</value>
            </property>
            <!--maxActive: 最大连接数量 -->
            <property name="maxActive">
                <value>${maxActive}</value>
            </property>
            <!--initialSize: 初始化连接 -->
            <property name="initialSize">
                <value>${initialSize}</value>
            </property>
            <!--maxIdle: 最大空闲连接 -->
            <!-- <property name="maxIdle" value="${maxIdle}" /> -->
            <!--minIdle: 最小空闲连接 -->
            <property name="minIdle">
                <value>${minIdle}</value>
            </property>
    
            <!-- 在进行borrowObject进行处理时,对拿到的connection进行validateObject校验 -->
            <property name="testOnBorrow">
                <value>false</value>
            </property>
            <!-- 在进行returnObject对返回的connection进行validateObject校验 -->
            <property name="testOnReturn">
                <value>false</value>
            </property>
            <!--是否要进行检测连接有效 -->
            <property name="testWhileIdle">
                <value>true</value>
            </property>
            <!--进行检测使用的有效的SQL语句 -->
    <!--         <property name="validationQuery">
                <value>SELECT 1</value>
            </property> -->
    
            <!--每隔多少时间检测一次(默认毫秒),根据mysql:wait_timeout值来设定 -->
            <property name="timeBetweenEvictionRunsMillis">
                <value>${timeBetweenEvictionRunsMillis}</value>
            </property>
            <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
            <property name="minEvictableIdleTimeMillis">
                <value>${minEvictableIdleTimeMillis}</value>
            </property>
    
            <!-- 开启池的prepared statement 池功能 -->
            <property name="poolPreparedStatements">
                <value>true</value>
            </property>
            <!-- 不限制 statement池能够同时分配的打开的statements的最大数量, 如果设置为0表示不限制 -->
            <!-- <property name="maxOpenPreparedStatements" value="${maxOpenPreparedStatements}"></property> -->
    
    
            <!-- 超过removeAbandonedTimeout时间后,是否进行没用连接(废弃)的回收(默认为false) -->
            <property name="removeAbandoned" value="${removeAbandoned}" />
            <!-- 超过时间限制,回收没有用(废弃)的连接(单位秒,默认为 300秒,5分钟) -->
            <property name="removeAbandonedTimeout" value="${removeAbandonedTimeout}" />
            <!--每次检查链接的数量,建议设置和maxActive一样大,这样每次可以有效检查所有的链接.(默认为3个) -->
            <property name="numTestsPerEvictionRun" value="${numTestsPerEvictionRun}" />
            <!-- 关闭abanded连接时输出错误日志 -->
            <property name="logAbandoned" value="${logAbandoned}"></property>
        </bean>
    
        <!-- mybatis-spring整合 -->
        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="configLocation" value="classpath:mybatis-config.xml" />
            <!-- 自动扫描entity目录, 省掉mybatis-config.xml里的手工配置 -->
            <property name="mapperLocations">
                <list>
                    <!-- mapper接口对应的xml路径 如果mapper接口的保内有和接口名一致的xml 则不用配置这个 -->
                    <value>classpath:com/test/mapper/*Mapper.xml</value>
                </list>
            </property>
        </bean>
    
        <!-- 自动扫描mybatis映射 -->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="com.salesproject.mapper"/>
        </bean>
    
        <!-- 事务 -->
        <bean name="transactionManager"
            class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource" />
        </bean>
    
        <!-- 可通过注解控制事务 -->
        <tx:annotation-driven transaction-manager="transactionManager" />
    
        <!-- 事务通知 -->
        <tx:advice id="txAdvice" transaction-manager="transactionManager">
            <tx:attributes>
                <!-- REQUIRED:指定当前方法必需在事务环境中运行,如果当前有事务环境就加入当前正在执行的事务环境, 如果当前没有事务,就新建一个事务。这是默认值。 
                    SUPPORTS:指定当前方法加入当前事务环境,如果当前没有事务,就以非事务方式执行。 -->
                <tx:method name="insert*" propagation="REQUIRED"
                    rollback-for="java.lang.Exception" />
                <tx:method name="update*" propagation="REQUIRED"
                    rollback-for="java.lang.Exception" />
                <tx:method name="delete*" propagation="REQUIRED"
                    rollback-for="java.lang.Exception" />
                <tx:method name="*" propagation="SUPPORTS" read-only="true" />
            </tx:attributes>
        </tx:advice>
    
        <!-- 方法调用时间记录 -->
        <bean id="methodExecuteTime" class="com.common.aspect.Aspect" />
    
        <!-- Spring AOP config (* com.salesproject.service.*.*(..))中几个通配符的含义: 第一个 * :通配
            任意返回值类型 第二个 * :通配 包com.salesproject.service下的任意class 第三个 * :通配 包com.salesproject.service下的任意class的任意方法
            第四个 .. :通配 方法可以有0个或多个参数 -->
        <aop:aspectj-autoproxy proxy-target-class="true" expose-proxy="true"/>
        <aop:config proxy-target-class="true">
            <aop:pointcut id="serviceMethods" expression="execution(* com.test.service..*.*(..))" />
            <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" order="2" />
        </aop:config>
    
        <import resource="classpath:spring/spring-test-provider.xml" />
        <import resource="classpath:spring/dubbo-service-consumer.xml" />
    
    </beans>

    spring-test-provider.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                             http://code.alibabatech.com/schema/dubbo
                              http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
        <!-- 提供方应用信息,用于计算依赖关系 -->
        <!--<dubbo:application name="${dubbo.application.name}" />-->
    
        <!-- 使用zookeeper注册中心暴露服务地址 即zookeeper的所在服务器ip地址和端口号 -->
        <dubbo:registry protocol="zookeeper" address="${dubbo.registry.address}" check="false" />
        <!-- 用dubbo协议在20880端口暴露服务 -->
        <!--<dubbo:protocol name="${dubbo.protocol.name}" port="${dubbo.protocol.port}" />-->
    
        <!-- 声明需要暴露的服务接口 -->
        <!--test信息服务-->
        <bean id="testService" class = "com.test.impl.TestServiceImpl"/>
        <dubbo:service interface = "com.test.service.TestService" ref = "testService" version="1.0.0" timeout="20000"/>
    
    </beans>

    config.properties:

    #连接池中可同时连接的最大的连接数(默认值为8)1000
    maxActive=100
    # 初始化连接(默认为0)10
    initialSize=5
    #连接池中最大的空闲的连接数,超过的空闲连接将被释放,如果设置为负数表示不限制(默认为8个)10
    maxIdle=10
    #连接池中最小的空闲的连接数,低于这个数量会被创建新的连接(默认为0个)10
    minIdle=10
    #最大等待时间,当没有可用连接时,连接池等待连接释放的最大时间,超过该时间限制会抛出异常(默认为-1表示无限等待)(单位为 ms)9秒
    maxWait=9000
    #关闭abanded连接时输出错误日志
    logAbandoned=true
    #超过removeAbandonedTimeout时间后,是否进行没用连接(废弃)的回收(默认为false)
    removeAbandoned=true
    #超过时间限制,回收没有用(废弃)的连接(单位秒,默认为 300秒,5分钟) 2分半
    removeAbandonedTimeout=150
    
    ########## validate ##########
    #每次检查链接的数量,建议设置和maxActive一样大,这样每次可以有效检查所有的链接.(默认为3个)100
    numTestsPerEvictionRun=100
    #每隔多少时间检测一次(默认毫秒),根据mysql:wait_timeout值来设定 100秒
    timeBetweenEvictionRunsMillis=100000
    #连接池中连接,在时间段内一直空闲, 被逐出连接池的时间(单位毫秒,默认为 1800000L,30分钟)
    minEvictableIdleTimeMillis=1800000
    #不限制  statement池能够同时分配的打开的statements的最大数量, 如果设置为0表示不限制
    maxOpenPreparedStatements=20
    ########## validate ##########
    
    ###############mysql数据源###################
    # 测试环境
    #db.crm.url=***
    #db.crm.user=***
    #db.crm.pwd=***
    # 开发环境
    db.crm.url=***
    db.crm.user=***
    db.crm.pwd=***

    dubbo.properties:

    dubbo.application.name=sales-project-external-provider
    dubbo.protocol.name=dubbo
    dubbo.protocol.port=30889
    #dubbo.registry.file=/root/.dubbo/pes-dubbo-registry.properties
    dubbo.log4j.file=logs/sales-project-external-provider.log
    dubbo.registry.address=127.0.0.1:2181

    log4j.properties:

    log.dir=/var/log/sales-project-external-provider
    log4j.rootLogger=debug,stdout,root
    log4j.logger.org.springframework=debug,root
    #log4j
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{5}:%L: %m%n
    #org.springframework
    log4j.appender.root=org.apache.log4j.RollingFileAppender
    log4j.appender.root.File=${log.dir}/springframework.log
    log4j.appender.root.MaxFileSize=50MB
    log4j.appender.root.MaxBackupIndex=5
    log4j.appender.root.layout=org.apache.log4j.PatternLayout
    log4j.appender.root.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{5}:%L: %m%n

    mybatis-config.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
    
    <configuration>
        
        <typeAliases>
            <!-- <typeAlias alias="member1" type="com.ryfinance.entity.Member" /> -->
        </typeAliases>
        <plugins>
        <!-- com.github.pagehelper为PageHelper类所在包名 -->
        <plugin interceptor="com.github.pagehelper.PageHelper">
            <property name="dialect" value="mysql"/>
            <!-- 该参数默认为false -->
            <!-- 设置为true时,会将RowBounds第一个参数offset当成pageNum页码使用 -->
            <!-- 和startPage中的pageNum效果一样-->
            <property name="offsetAsPageNum" value="true"/>
            <!-- 该参数默认为false -->
            <!-- 设置为true时,使用RowBounds分页会进行count查询 -->
            <property name="rowBoundsWithCount" value="true"/>
            
            <!-- 设置为true时,如果pageSize=0或者RowBounds.limit = 0就会查询出全部的结果 -->
            <!-- (相当于没有执行分页查询,但是返回结果仍然是Page类型)
            <property name="pageSizeZero" value="true"/>-->
            
            <!-- 3.3.0版本可用 - 分页参数合理化,默认false禁用 -->
            <!-- 启用合理化时,如果pageNum<1会查询第一页,如果pageNum>pages会查询最后一页 -->
            <!-- 禁用合理化时,如果pageNum<1或pageNum>pages会返回空数据 -->
            <property name="reasonable" value="false"/>
            <!-- 3.5.0版本可用 - 为了支持startPage(Object params)方法 -->
            <!-- 增加了一个`params`参数来配置参数映射,用于从Map或ServletRequest中取值 -->
            <!-- 可以配置pageNum,pageSize,count,pageSizeZero,reasonable,不配置映射的用默认值 -->
            <!-- 不理解该含义的前提下,不要随便复制该配置 
            <property name="params" value="pageNum=start;pageSize=limit;"/>    -->
        </plugin>
      </plugins>
    </configuration>
      

    test-web的配置:

    applicationContext.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
                            http://www.springframework.org/schema/context/spring-context.xsd">
    
        <!-- 引入config.properties文件 -->
        <bean id="placeholderConfig"
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:config.properties</value>
                    <value>classpath:dubbo.properties</value>
                </list>
            </property>
        </bean>
    
        <!-- 导入配置文件 -->
        <import resource="classpath:spring/dubbo-server-consumer.xml" />
    
        <bean class="com.common.listener.MyApplicationContextAware" />
    
    </beans>

    dubbo-server-consumer.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                             http://code.alibabatech.com/schema/dubbo
                              http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
    
    
        <!-- 提供方应用信息,用于计算依赖关系 -->
        <!--<dubbo:application name="${dubbo.application.name}" />-->
        <!-- 使用multicast广播注册中心暴露服务地址 -->
        <!-- <dubbo:registry address="multicast://224.5.6.7:1234" /> -->
        <!-- 使用zookeeper注册中心暴露服务地址 即zookeeper的所在服务器ip地址和端口号 -->
        <dubbo:registry protocol="zookeeper" address="${dubbo.registry.address}" check="false" />
        <!--员工管理系统服务-->
        <dubbo:reference id="testService" interface="com.test.service.TestService" version="1.0.0" timeout="20000" retries="0" />
    
    </beans>

    spring-mvc.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xsi:schemaLocation="http://www.springframework.org/schema/mvc
                            http://www.springframework.org/schema/mvc/spring-mvc.xsd
                            http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
                              http://www.springframework.org/schema/context/spring-context.xsd
                              http://www.springframework.org/schema/aop
                              http://www.springframework.org/schema/aop/spring-aop.xsd">
        <aop:aspectj-autoproxy proxy-target-class="true"/>
        <mvc:annotation-driven/>
        <!--注解控测器 设置使用注解的类所在的jar包 -->
        <context:component-scan base-package="com.test"/>
    
    
        <!-- 对静态资源文件的访问,交给default servlet handler处理 -->
        <mvc:default-servlet-handler />
        <bean id="contentNegotiationManager"
            class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
            <property name="favorParameter" value="false" />
            <!-- 设置为true以忽略对Accept Header的支持 -->
            <property name="ignoreAcceptHeader" value="true" />
    
            <!-- 在没有扩展名时即: "/blog/1" 时的默认展现形式 -->
            <property name="defaultContentType" value="text/html" />
    
            <!-- 扩展名至mimeType的映射,即 /blog.json => application/json -->
            <property name="mediaTypes">
                <map>
                    <entry key="html" value="text/html" />
                    <entry key="json" value="application/json" />
    
                    <!-- 后续需要支持这些格式,再放开 <entry key="pdf" value="application/pdf" /> <entry 
                        key="xsl" value="application/vnd.ms-excel" /> <entry key="xml" value="application/xml" 
                        /> -->
                </map>
            </property>
        </bean>
    
        <bean
            class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
            <property name="order" value="1" />
            <property name="contentNegotiationManager" ref="contentNegotiationManager" />
    
            <property name="viewResolvers">
                <list>
                    <bean
                        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                        <property name="viewClass"
                            value="org.springframework.web.servlet.view.JstlView" />
                        <property name="prefix" value="/" />
                        <property name="suffix" value=".html" />
                    </bean>
                </list>
            </property>
    
            <property name="defaultViews">
                <list>
                    <!-- application/json ModelAndView里的数据变成JSON -->
                    <bean
                        class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
                    <!-- application/xml -->
                    <!-- <bean class="org.springframework.web.servlet.view.xml.MarshallingView"> 
                        <property name="marshaller"> <bean class="org.springframework.oxm.xstream.XStreamMarshaller"> 
                        </bean> </property> </bean> -->
                </list>
            </property>
        </bean>
    
    
        <!-- 文件上传解析器 id 必须为multipartResolver 10M -->
        <bean id="multipartResolver"
            class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
            <!-- 上传的最大字节数,-1代表没有任何限制 1024*1024*4=4194304即4m -->
            <!--<property name="maxUploadSize" value="4194304" />-->
            <property name="maxUploadSize" value="10485760" />
            <!-- 读取文件到内存中最大的字节数,默认是1024 -->
            <property name="maxInMemorySize" value="1024" />
            <!-- 文件上传头部编码,默认是iso-8859-1,注意defaultEncoding必须和前端页面pageEncoding属性一致,以便能正常读取文件 -->
            <property name="defaultEncoding" value="UTF-8" />
            <!-- 文件上传暂存目录,文件上传完成之后会清除该目录,模式是在servlet容器的临时目录,例如tomcat的话,就是在tomcat文件夹的temp目录 -->
            <!--<property name="uploadTempDir" value="/upload" />-->
        </bean>
    
        <bean class="com.test.base.swagger.SalesProjectSwaggerConfig" />
        <bean class="com.test.base.resolver.MySimpleMappingExceptionResolver" />
    
        <bean id="methodExecuteTime" class="com.common.aspect.Aspect" />
    
        <aop:config>
            <aop:aspect id="logMethodExecuteTime" ref="methodExecuteTime" >
                <aop:pointcut id="controllerMethods" expression="execution(* com.test.controller..*.*(..))" />
                <aop:around method="methodExecuteTime" pointcut-ref="controllerMethods" />
            </aop:aspect>
        </aop:config>
    </beans>

    config.properties:

    #权限系统配置
    rbac.system=21
    #单点登录站点
    sso.web.site=http://user.chtwm.com:8080
    #单点登录域名
    sso.web.domain=chtwm.com

    dubbo.properties:

    dubbo.application.name=sales-project-cms-web-consumer
    dubbo.log4j.file=logs/sales-project-cms-web-consumer.log
    dubbo.registry.address=127.0.0.1:2181

    log4j.properties:

    log.dir=/var/log/test
    log4j.rootLogger=debug,stdout,root
    log4j.logger.org.springframework=debug,root
    #log4j
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{5}:%L: %m%n
    #org.springframework
    log4j.appender.root=org.apache.log4j.RollingFileAppender
    log4j.appender.root.File=${log.dir}/springframework.log
    log4j.appender.root.MaxFileSize=50MB
    log4j.appender.root.MaxBackupIndex=5
    log4j.appender.root.layout=org.apache.log4j.PatternLayout
    log4j.appender.root.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{5}:%L: %m%n

    web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
             version="2.5">
    
        <display-name>test-web</display-name>
    
        <session-config>
            <session-timeout>30</session-timeout>
        </session-config>
    
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring/applicationContext.xml</param-value>
        </context-param>
    
        <filter>
            <filter-name>springEncoding</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>utf-8</param-value>
            </init-param>
            <init-param>
                <!-- 是否强制设在request编码 -->
                <param-name>forceEncoding</param-name>
                <param-value>true</param-value>
            </init-param>
        </filter>
        <filter-mapping>
            <filter-name>springEncoding</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
        <servlet>
            <servlet-name>springMVC</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath:spring/spring-mvc.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>springMVC</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    
        <listener>
            <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
        </listener>
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <listener>
            <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
        </listener>
    
    </web-app>

    4.安装zookeeper

    参考网上安装方法,安装完成后,设置zoo.cfg配置文件,启动zookeeper

    5.结果

    启动provicer,启动web,swagger-ui测试。

    可以看到controller调用dubbo接口并进入dubbo接口的断点。

    至此,dubbo环境搭建成功。

  • 相关阅读:
    Spring源码加载BeanDefinition过程
    设计模式之☞委派模式,通俗易懂,一学就会!!!
    SpringMvc 跨域处理
    寻找全排列的下一个数
    使用两个栈实现队列
    无序数组在排序后的最大相邻查
    判断一个数是否是2的幂
    最大公约数
    最小栈的实现
    js 原型与原型链
  • 原文地址:https://www.cnblogs.com/super-chao/p/9603295.html
Copyright © 2011-2022 走看看