0
私の質問は簡単です。以下のクラスを考えてみましょう。 @Valueアノテーションを使ってプロパティファイルを使わずに、i = 1、str = "abc"という値を直接配置する必要があります。どうやってするか ?春@valueプロパティファイルなしで値を注入する
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class Example {
int i;
String str;
@Autowired
AccountService obj;
public void setI(int i) {
this.i = i;
}
public void setStr(String str) {
this.str = str;
}
public void setObj(AccountService obj) {
this.obj = obj;
}
}
すごく分かりませんでした。私は私の答えを削除します。 +1 –