I think what you are after is this:
@Component
public class MyBean {
private String xmlFile;
private String xsdFile;
@Autowired
public MyBean(@Value("$MYDIR/myfile.xml") final String xmlFile,
@Value("$MYDIR/myfile.xsd") final String xsdFile) {
this.xmlFile = xmlFile;
this.xsdFile = xsdFile;
}
//methods
}
You also might want these files to be configurable via system properties. You can use the @Value
annotation to read system properties using the PropertyPlaceholderConfigurer
, and the ${}
syntax.
To do this, you can use different String
values in your @Value
annotation:
@Value("${my.xml.file.property}")
@Value("${my.xsd.file.property}")
but you will also need these properties in your system properties:
my.xml.file.property=$MYDIR/myfile.xml
my.xsd.file.property=$MYDIR/myfile.xsd