Estos son mis principios. Si a usted no le gustan, tengo otros

Spring Annotations Inject properties / Anotaciones Spring Inyectar properties

Posted: December 4th, 2009 | Author: Edu | Filed under: Java, Spring | Tags: , | No Comments »
VN:F [1.9.2_1090]
Rating: 0.0/5 (0 votes cast)

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;
    }
}
VN:F [1.9.2_1090]
Rating: 0.0/5 (0 votes cast)


Leave a Reply

  • Powered by WP Hashcash