美文网首页
SpringBoot整合dubbo

SpringBoot整合dubbo

作者: 扎哈_ | 来源:发表于2018-06-21 07:26 被阅读0次

    首先创建一个多模块Maven项目,再创建一个生产者子项目和一个消费者子项目。
    父模块Maven POM文件如下:

    <?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>org.nc.school</groupId>
      <artifactId>school_manage</artifactId>
      <version>1.0-SNAPSHOT</version>
      <name>school_manage</name>
      <description>学校管理系统</description>
      <modules>
        <module>school_manage-server</module>
        <module>school_manage-web</module>
      </modules>
      <packaging>pom</packaging>
    
    
    
      <properties>
        <junit.version>4.12</junit.version>
        <zookeeper.version>3.4.12</zookeeper.version>
        <spring-boot-starter-dubbo.version>1.0.0</spring-boot-starter-dubbo.version>
        <spring-booot.version>2.0.3.RELEASE</spring-booot.version>
      </properties>
    
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>${junit.version}</version>
          <scope>test</scope>
        </dependency>
    
    
      </dependencies>
    
      <build>
        <finalName>${project.artifactId}</finalName>
          <plugins>
            <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
          </plugins>
      </build>
    </project>
    
    

    生产者POM文件如下:

    <?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>school_manage</artifactId>
            <groupId>org.nc.school</groupId>
            <version>1.0-SNAPSHOT</version>
            <relativePath>school_manage/pom.xml</relativePath>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>school_manage-server</artifactId>
        <packaging>jar</packaging>
        <name>school_manage-server</name>
        <description>学校管理系统服务提供者</description>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>${spring-booot.version}</version>
            </dependency>
    
            <dependency>
                <groupId>io.dubbo.springboot</groupId>
                <artifactId>spring-boot-starter-dubbo</artifactId>
                <version>${spring-boot-starter-dubbo.version}</version>
            </dependency>
    
            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>${zookeeper.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>2.0.3.RELEASE</version>
                    <configuration>
                        <mainClass>org.nc.school.Startup</mainClass> <!--主类 包含main-->
                        <layout>JAR</layout> <!---包类型(必须大写) JAR,WAR,ZIP,MODULE,NONE-->
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    
    

    消费者POM文件如下:

    <?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>school_manage</artifactId>
            <groupId>org.nc.school</groupId>
            <version>1.0-SNAPSHOT</version>
            <relativePath>school_manage/pom.xml</relativePath>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>school_manage-web</artifactId>
        <packaging>war</packaging>
    
        <name>school_manage-web</name>
        <description>学校管理系统消费者</description>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>2.0.3.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>io.dubbo.springboot</groupId>
                <artifactId>spring-boot-starter-dubbo</artifactId>
                <version>1.0.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>${zookeeper.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.nc.school</groupId>
                <artifactId>school_manage-server</artifactId>
                <version>1.0-SNAPSHOT</version>
            </dependency>
        </dependencies>
    
        <build>
            <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </project>
    
    

    相关文章

      网友评论

          本文标题:SpringBoot整合dubbo

          本文链接:https://www.haomeiwen.com/subject/wygfyftx.html