spring配置文件拆分细节注意

1.在配置applicationContext-dao.xml中,如果加载资源文件 jdbc.properties 和 dataSource 配置 不在同一个文件时,注意对jdbc.properties的扫描路径采用classpath*:

例如:将spring-dao.xml 拆分为: applicationContext-source.xml 和 applicationContext-dao.xml

applictionContext-source.xml 




	
	

applictionContext-dao.xml




    
        
        
        
        

        
        

    

    
    
        
        
        
        
        
        
        
        
    


否则在测试时报错:

java.lang.IllegalStateException: Failed to load ApplicationContext

 ... more

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in file [G:\ADataIDEA\TestMaven\target\classes\applicationContext-dao.xml]: Could not resolve placeholder 'jdbc_driver' in value "${jdbc_driver}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jdbc_driver' in value "${jdbc_driver}"

 ... more

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'jdbc_driver' in value "${jdbc_driver}"
	
 ...  more

2.1.在配置applicationContext-dao.xml中,如果加载资源文件 jdbc.properties 和 dataSource 配置 不在同一个文件时,注意不可多次扫描  jdbc.properties 配置文件

Could not resolve placeholder 'jdbc.driver' in string value "${jdbc.driver}"

参考:https://blog.csdn.net/Daisy621/article/details/77054023/

你可能感兴趣的:(Error,SSM,Spring)