Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 Spring 控制器,并且有一个 String 参数我想注入到这个控制器中。所以我正在考虑向接受字符串作为参数的控制器添加一个新的构造函数。这是一个不好的做法,因为 Spring 控制器是单例的?
您可以改为注入您的 String 参数:
@Value("${dropbox.access-token") private String accessToken;