SpringBootBucket icon indicating copy to clipboard operation
SpringBootBucket copied to clipboard

springboot多数据源配置启动一直报这个错啊,请问时怎么回事?

Open wccJava opened this issue 5 years ago • 5 comments

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [D:\IDEA\idea2019\springboot\springboot-datasource\target\classes\com\spring\datasource\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

wccJava avatar Jun 05 '19 11:06 wccJava

你看看你是不是没有注入sqlSessionFactory  和 sqlSessionTemplate。或者没有写@Bean注解。另外还有可能是你注入这两个的时候没有指定名字。发自我的华为手机-------- 原始邮件 --------主题:[yidao620c/SpringBootBucket] springboot多数据源配置启动一直报这个错啊,请问时怎么回事? (#15)发件人:wccJava 收件人:yidao620c/SpringBootBucket 抄送:Subscribed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [D:\IDEA\idea2019\springboot\springboot-datasource\target\classes\com\spring\datasource\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

lzyqssn avatar Jun 05 '19 11:06 lzyqssn

@lzyqssn 感谢您的回答!我仔细看了demo发现并没有对这两点进行注入,如果注入,请问如何注入?

wccJava avatar Jun 05 '19 12:06 wccJava

提供一下你的代码看看。

------------------ 原始邮件 ------------------ 发件人: "wccJava"[email protected]; 发送时间: 2019年6月5日(星期三) 晚上8:00 收件人: "yidao620c/SpringBootBucket"[email protected]; 抄送: "1097842122"[email protected];"Mention"[email protected]; 主题: Re: [yidao620c/SpringBootBucket] springboot多数据源配置启动一直报这个错啊,请问时怎么回事? (#15)

@lzyqssn 感谢您的回答!我仔细看了demo发现并没有对这两点进行注入,如果注入,请问如何注入?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

lzyqssn avatar Jun 05 '19 12:06 lzyqssn

@lzyqssn 我明天把工程打包发您邮件,如果您有空可以帮我看看!感谢!

wccJava avatar Jun 05 '19 12:06 wccJava

@lzyqssn 您好我已经发送demo到您的邮箱上了,您有空可以的话指点一下!谢谢!

wccJava avatar Jun 06 '19 01:06 wccJava