记一次自己搭建springboot、dubbo项目过程及踩坑
搭建按照百度的文章,https://www.cnblogs.com/kitor/p/11016665.html
主要遇到的是打包、依赖引用问题。下面我按顺序说一下我遇到及解决问题的过程。
先把解决问题的文档发出来吧,作者写的很清晰。关于springboot打包。https://segmentfault.com/a/1190000019706787
1.遇到的第一个问题是,将项目打包后,在服务器上面mvn clean install。打完包,使用
java -jar provider-0.0.1-SNAPSHOT.jar
启动项目,发现启动报
没有主清单属性,直观原因是找不到启动类,在/target/META-INF/MANIFEST.MF文件里面没有
Main-Class: com.lsy.dubbo.provider.ProviderApplication
这个配置(其实是因为没有使用springboot-maven打成可执行jar包,这里我打出的jar就是普通的、可以被其他服务引用的jar)
解决方法:https://www.cnblogs.com/showxiaxian/p/4826568.html
修改MANIFEST.MF文件路径:点击加号-jar-from module
2.这样修改之后,发现provider服务既可以打包,又可以执行了,但是改完又引发了另一个问题:consumer打包时提示,依赖的provider包找不到。
在经过苦苦百度后,lcl找到并提示我在pom.xml中添加这行:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.5.RELEASE</version>
<configuration>
<classifier>exec</classifier>
<executable>true</executable>
<includeSystemScope>true</includeSystemScope>
<mainClass>com.lsy.dubbo.provider.ProviderApplication</mainClass>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
开头粘出的链接可以解释并解决如上问题,https://segmentfault.com/a/1190000019706787