Spring Annotations Inject properties / Anotaciones Spring Inyectar properties
Posted: December 4th, 2009 | Author: Edu | Filed under: Java, Spring | Tags: Java, Spring | No Comments »applicationContext.xml:
File parameters.properties / Fichero parameters.properties:
MyComponent.path=/some/path
Spring component / Componente gestionado por Spring:
import javax.annotation.PostConstruct; import org.springframework.stereotype.Component; @Component("MyComponent") public class MyComponent { private String path; @PostConstruct public void loadPath() { System.out.println("Loading from " + this.path); } public String getPath() { return path; } public void setPath(String path) { this.path = path; } }
Leave a Reply