Injecting a classpath resource into a Spring 3 bean

If it’s going to be hard-coded like that, then just

private Resource sqlFile = new ClassPathResource("/abc/student/test.sql");

Otherwise, what you’re really after is

@Value("${some.property}")
private Resource sqlFile;

and I believe that in injecting the property value, the correct PropertyEditor will be applied.

Leave a Comment