springboot+dubbo项目运行主jar时找不到rpc的bean

springboot+dubbo项目运行主jar时找不到rpc的bean

  1. resources目录下有conf目录,里面放置dubbo.xml和所要调用dubbo服务的其他dubbo.xml
  2. 打包时如果把这个conf打进jar中,项目可以运行,如果把conf不打进jar,linux启动jar时会报错
    APPLICATION FAILED TO START
    Description:
    A component required a bean named ‘xxxxxxxxxxxxxxxxxxxRpc’ that could not be found.
    Action:
    Consider defining a bean named ‘xxxxxxxxxxxxxxxxxxxRpc’ in your configuration.

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.Properties;

// 不用默认配置的数据源,自己配置
@SpringBootApplication(scanBasePackages = “com.pakege”,
exclude = {DataSourceAutoConfiguration.class, FlywayAutoConfiguration.class})
@EnableAspectJAutoProxy
@ServletComponentScan
@ImportResource(locations = {“classpath*:conf/*.xml”})
public class PybbsApplication {
public static void main(String[] args) {
SpringApplication.run(PybbsApplication.class, args);
}
分析:一般这种问题要么是没加载到配置文件,要么是配置文件里面配置路径不对
不知道为什么我的项目把dubbo配置文件不打在jar里面就找不到,可能是哪里写的有问题;
解决办法:
因为项目不会去加载jar外面的配置文件,在dubbo.xml配置<dubbo:registry address=“zookeeper://” />直接去注册中心找就行了,就不用再其他的dubbo.xml配置url

项目是从GitHub上down下来的,所以在对接其他项目的时候会有很多问题

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值