1、创建maven
2.删除src目录
3.添加基于SpringBoot的三个子模块dubbo-api、dubbo-provider、dubbo-customer
添加子模块dubbo-api,项目右键–>new–>Module
Animal:
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Animal implements Serializable {
private int aid;
private String aname;
private int age;
private String sex;
private int feetcount;
}
AnimalService.java:
public interface AnimalService {
List<Animal> findAll();
Animal findById(int aid);
}
写完之后,对该模块进行clean->compile->package->install
找到该模块下面的这个文件
用解压软件打开,如果出现下面这个路径,就说明错了
解决该问题:
在主模块的pom.xml中加入(buid中就加入这些东西):
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<locales>en,fr</locales>
</configuration>
</plugin>
<!--打包时,不出现 boot-info的解决方案-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!--子模块找不到测试类的解决方法-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
子模块pom.xml(覆盖里面的plugin):
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
重新执行上面的打包过程,出现下面这个目录结构就对了
添加子模块dubbo-provider,项目右键–>new–>Module
子模块添加依赖:
<--自定义依赖,就是刚才dubbo-api安装的依赖 -->
<dependency>
<groupId>com.wance</groupId>
<artifactId>dubbo-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<--dubbo起步依赖 -->
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>LATEST</version>
</dependency>
<-- zookeeper客户端依赖-->
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>
建立dubbo-consumer模块
子模块添加pom.xml依赖:
<--自定义依赖,就是刚才dubbo-api安装的依赖 -->
<dependency>
<groupId>com.wance</groupId>
<artifactId>dubbo-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<--dubbo起步依赖 -->
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>LATEST</version>
</dependency>
<-- zookeeper客户端依赖-->
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>