首先在提供者和消费者的pom.xml中添加数据源的依赖 放在build即可
build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/**</include> </includes> </resource> <resource> <directory>src/main/webapp</directory> <includes> <include>**/**</include> </includes> </resource> <!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 https://www.jianshu.com/p/836d455663da --> <resource> <directory>src/main/java</directory> <includes> <include>**/*.yml</include> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.yml</include> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources/static</directory> <includes> <include>**/**</include> </includes> </resource> </resources> </build> 先将common中pom.xml类型为jar 的时候 maven clean--->maven install 打出一个包 再在common中pom.xml中把jar改为pom maven update 刷新common 更新项目-->再maven clean--->maven install 如果成功就可以打包了 点击项目右键properties->Resource->点击Location右边的黄色箭头--》进入工作空间 双击要打包的项目-->在目录上输入cmd进入黑窗口->输入 运行maven命令,打包 mvn clean package -Dmaven.test.skip=true war包就在本项目的target文件夹中了 开启zookeeper和tomcat 登陆Dubbo官网 谷歌输入http://localhost:8088/dubbo-admin-2.5.4进入DUBBO 点击提供者项目右键properties->Resource->点击Location右边的黄色箭头--》进入工作空间 进入target 因为war包就在target中 点击上方路径 输入cmd 进入黑窗口 在黑窗口中显示当下路径是D:/workspace-sts-smallfive/week3-provider/target> 通过 java -jar 命令运行一个jar包或war包 输入 java -jar week3-provider-0.0.1-SNAPSHOT.war 先提供者 后消费者 查看官网服务