0
クラスパス上のファイルの内容を、対応するクラスの作成時にメンバ変数に挿入することはできますか?クラスパスから注釈付きメンバにファイルの内容を挿入する
@Component
public class MyClass {
@Value("classpath:my_file.txt")
private String myFile;
}
クラスパス上のファイルの内容を、対応するクラスの作成時にメンバ変数に挿入することはできますか?クラスパスから注釈付きメンバにファイルの内容を挿入する
@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