Spring Property-placeholder Mapperscannerconfigurer Unable to read configuration resolution

Source: Internet
Author: User

When using Org.mybatis.spring.mapper.MapperScannerConfigurer for automatic scanning in spring, the sqlsessionfactory is set. May cause Propertyplaceholderconfigurer to fail, that is, an expression such as ${jdbc.username} will not be able to get to the content in the properties file. This is caused by the fact that Mapperscannerconigurer is actually parsing the load bean definition phase, which, if set sqlsessionfactory, causes some classes to be initialized in advance, this time, Propertyplaceholderconfigurer has not had time to replace the variables in the definition, causing the expression to be copied as a string.

So in the configuration

<Bean id= "sqlsessionfactory" class= "Org.mybatis.spring.SqlSessionFactoryBean " Name= "Sqlsessionfactoryname">

When setting a unique name

When configuring Mapperscannerconfigurer,

<property Name= "Sqlsessionfactorybeanname" value= "Sqlsessionfactoryname" />

To complete the injection

Spring Property-placeholder Mapperscannerconfigurer Unable to read configuration resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.