通过@Value注解读取.properties配置内容

时间:2025-02-13 15:34:59
@Controller
@RequestMapping("/value")
public class ValuePropertyController extends ApplicationController{
    
	@Value("#{configProperties['']}")
	private String jdbcUrl; 
	
	@RequestMapping
	public String value(){
		(jdbcUrl);
		return "";
	}
}


<bean  class="">
       <property name="locations">
           <list>
               <value>classpath:</value>
           </list>
       </property>
    </bean>
    <bean  class="">
        <property name="properties" ref="configProperties" />
    </bean>

=jdbc:mysql://localhost:3306/commentDemo?useUnicode=true&characterEncoding=UTF-8