Could not resolve Spring property placeholder

前端 未结 7 2415
有刺的猬
有刺的猬 2020-11-27 15:13

I have my config:





        
7条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 15:45

    Your property file location is classpath:idm.properties

    This is rather unusual, it means that idm.properties must be located either at the top level of WEB-INF/classes or at the top-level of one of the jars inside WEB-INF/lib. Usually it's good practice to either use a dedicated folder for properties or keep them close to the context files that use them.

    So my suggestion is this: Is your properties file perhaps next to your context file? If so, it's not on the classpath (see this question: Is WEB-INF in the CLASSPATH?).

    The classpath: prefix maps to a ClassPathResource, but you probably need a ServletContextResource, and you'll get that from a WebApplicationContext using the syntax without prefix:

    
    

    Reference:

    • The ResourceLoader
      (describes how different ApplicationContext types handle resources without prefix)
    • The PropertyPlaceholderConfigurer mechanism
      (describes the mechanism)

提交回复
热议问题