@Component
public class Bot extends TelegramLongPollingBot {
@Value("${camel.component.telegram.authorization-token}") //properties
private String botToken; //null
TelegramBot bot = TelegramBotAdapter.buildDebug(botToken);
.
.
.
}
我不明白为什么不注入属性中定义的参数值。
答案 0 :(得分:0)
请注意,@ Value不支持轻松绑定,因此请检查您的媒体资源。
答案 1 :(得分:0)
@Component
@PropertySource("file:${app_env_path}/${app_env}_DBconnection.properties")
public class DBProperties {
@Value("${driver.class.name}")
private String driverClassName;
@Value("${db.url}")
private String url;
@Value("${db.username}")
private String username;
@Value("${db.password}")
private String password;
@Value("${db.poolsize}")
private String poolsize;
//setters and getters
}
Property file -
driver.class.name=oracle.jdbc.OracleDriver
db.url=
db.username=
db.password=
db.poolsize=100
app_env_path =文件所在位置的路径 app_env = SIT / PROD