0
在構建相應的類時,是否可以將類路徑上的文件內容注入到成員變量中?Spring - 將文件內容從類路徑注入註釋成員
@Component
public class MyClass {
@Value("classpath:my_file.txt")
private String myFile;
}
在構建相應的類時,是否可以將類路徑上的文件內容注入到成員變量中?Spring - 將文件內容從類路徑注入註釋成員
@Component
public class MyClass {
@Value("classpath:my_file.txt")
private String myFile;
}
當然
import org.springframework.core.io.Resource;
@Value("classpath:my_file.txt")
private Resource myFile;
資源不是字符串! – AlexB
這是http://stackoverflow.com/questions/14639209/spring-expression-read-file-content的副本 – artemisian