我需要在应用程序启动后在Spring上下文中初始化bean; 目前,我使用注释@Configuration在类中初始化bean,如下所示:
@Configuration
public class AppConfig {
@Inject
@Bean
public BeanA init(param1, param2, etc...) {
--- Code to construct bean A ---
}
@Inject
@Bean
public BeanB init(param1, param2, etc...) {
--- Code to construct bean B ---
}
}
Run Code Online (Sandbox Code Playgroud)
但是我需要在应用程序启动后初始化一些bean,所以我的方法是创建一个类,在Spring中监听ApplicationReadyEvent事件,并将代码初始化为该类中的bean.
@Configuration
class ApplicationStartingListener implements ApplicationListener<ApplicationReadyEvent>{
---- Code to init bean here ----
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
--- If I put init bean code in here, is it correct? ----
}
}
Run Code Online (Sandbox Code Playgroud)
这是最好的方法吗?还是有其他更好的解决方案?
我正在使用WebBrowser控件显示“登录”页面,以供用户登录其帐户,然后应用程序将从该帐户获取联系人。
但是,问题是,如果用户从浏览器中选择选项“保持签名”,浏览器将缓存该帐户名,并使用不同的帐户进行下一次登录,它将返回先前缓存的帐户名。这导致应用程序将获得错误的帐户名。
你们知道如何在继续进行操作以防止此问题之前强制WebBrowser清除所有缓存吗?
我认为WebBrowser使用Internet Explorer,这是我计算机上的版本11。
我下载了 GlassFish 4.1.1 的 zip 文件,解压后,我使用终端使用asadmin start-domain命令启动服务器。它给了我这个错误:
Traceback (most recent call last):
File "/usr/local/bin/asadmin", line 260, in <module> autoscale = boto.connect_autoscale()
File "/Library/Python/2.7/site-packages/boto/__init__.py", line 208, in connect_autoscale**kwargs)
File "/Library/Python/2.7/site-packages/boto/ec2/autoscale/__init__.py", line 115, in __init__profile_name=profile_name)
File "/Library/Python/2.7/site-packages/boto/connection.py", line 1100, in __init__provider=provider)
File "/Library/Python/2.7/site-packages/boto/connection.py", line 569, in __init__host, config, self.provider, self._required_auth_capability())
File "/Library/Python/2.7/site-packages/boto/auth.py", line 997, in get_auth_handler 'Check your credentials' % (len(names), str(names))) boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your credentials
Run Code Online (Sandbox Code Playgroud)
我正在使用 MacOS Sierra …