草庐IT

Spring中bean的生命周期

全部标签

java - Spring 警告 : Request method 'HEAD' not supported

在tomcat7上成功部署后,我每秒收到警告消息:org.springframework.web.servlet.PageNotFoundhandleHttpRequestMethodNotSupportedWARNING:Requestmethod'HEAD'notsupported但是application作品。如何避免这个烦人的消息? 最佳答案 您需要在失败的方法上添加以下@RequestMapping(method={RequestMethod.GET,RequestMethod.HEAD})。这将允许他们处理HEAD请求并

java - 使用 Spring Security Filter 锁定除少数路由之外的所有内容

我们正在重新设计我们的产品以删除SpringSecurity中默认的“anonymousUser”行为,并希望锁定除少数端点之外的所有URL(通过过滤器安全性)。我们想不通的是如何指定“锁定除X、Y和Z之外的所有内容”我们的安全设置基本上归结为以下内容:@ConfigurationpublicclassSecurityConfigextendsWebSecurityConfigurerAdapter{@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException{http//disableanonymoususers.a

java - Unresolved 要求 : Require-Bundle: org. eclipse.core.databinding.beans;捆绑版本 ="1.2.200"

我正在尝试创建一个RCP应用程序,我想在其中绑定(bind)一个来自bean的变量以进行查看。bean的代码#publicclassSaveFileBeanimplementsPropertyChangeListener{privateStringtext;privatePropertyChangeSupportpropertyChangeSupport=newPropertyChangeSupport(this);@OverridepublicvoidpropertyChange(PropertyChangeEventarg0){propertyChangeSupport.fireP

java - Caused by : java. lang.IllegalStateException : Ambiguous mapping found. Cannot map 'appController' bean method

大家早上好,我正在处理一个我无法解码的模糊映射...我正在使用Springmvc4.0.6和hibernate4.3.6在tomcat中发起war时出现此错误:ERROR[localhost-startStop-2]:Contextinitializationfailedorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'requestMappingHandlerMapping'definedinclassorg.springframework.web.servlet.con

java - 将请求范围的 bean 注入(inject)另一个 bean

我想创建一个在请求生命周期中唯一的UUID。为此,我创建了一个带有@Scope("request")注释的UUIDbean。@Bean@Scope(scopeName=WebApplicationContext.SCOPE_REQUEST)publicUUIDrequestUUID(){returnUUID.randomUUID();}我想在我的Controller中访问这个bean。所以我用@Autowired注入(inject)它。这很好用。@ControllerpublicclassDashboardController{@AutowiredUUIDuuid;@Autowired

java - 如何在 Eclipse tomcat 中运行 spring boot 应用程序?

我有一个SpringBoot应用程序,想在Eclipse中将其作为服务器应用程序运行。因此,该应用程序将被识别为Tomcat网络应用程序,并且可以添加我更新方面:当我运行网络应用程序时,我的其余服务未被发现。SpringBoot应用程序包含的文件夹结构与SpringBoot发布之前的Spring应用程序不同。可以从配置为eclipse的tomcat运行springboot应用程序吗?同样在springboot之前,需要指定应用程序的Controller部分。我是否需要使用这些设置更新我的springboot应用程序才能从Eclipsetomcat运行?我不想创建一个war,然后将它复制

java - spring security - 在 UserDetailsS​​ervice 实现中访问请求参数

我正在开发一个javaspringmvc应用程序。我已经像这样实现了UserDetailsS​​ervice接口(interface):@Component@TransactionalpublicclassSecurityDAOimplementsUserDetailsService{@OverridepublicUserDetailsloadUserByUsername(finalStringusername)throwsUsernameNotFoundException{...}....}我需要在loadUserByUsername方法中找到用户登录url(因为该项目有多个登录ur

java - Spring Security >5.0.0 移除了 Md5PasswordEncoder

我有一个使用Spring安全性的Spring项目。我之前使用的是SpringBoot1.5,现在迁移到了SpringBoot2.0。我注意到Md5PasswordEncoder已在SpringSecurity的最终版本中删除。相反,即使已弃用(https://docs.spring.io/spring-security/site/docs/5.0.3.RELEASE/api/),Md4PasswordEncoder仍然存在。我应该使用外部MD5编码器还是将分类移动到其他地方? 最佳答案 Md5PasswordEncoder不复存在的

java - 创建名称为 'sessionFactory' 的 bean 时出错 : MalformedParameterizedTypeException

我们将不胜感激任何建议。我很难过...问题在我的笔记本电脑上,每当我们的应用程序尝试加载application-config.xml时,我都会收到java.lang.reflect.MalformedParameterizedTypeException。完全相同的代码适用于我的台式机和我同事的台式机/笔记本电脑。但是在我的笔记本电脑上它抛出了这个错误。由于我的笔记本电脑和台式机是完全相同的开发环境(MacOSXLeopard上Eclipse中的Java1.6Maven项目),我通过执行以下操作缩小了原因范围:从Subversioncheckout一个新项目(因此没有代码差异)复制并替换

java - Spring Injection - 在构造函数中访问注入(inject)的对象

我有一个资源(Springbean),它的一些字段由Spring注入(inject),例如:@Repository(value="appDao")publicclassAppDaoImplimplementsAppDao{@PersistenceContextEntityManagerentityManager;publicResource(){...useentityManager...//doesn'twork}}我知道我无法在构造函数中访问注入(inject)的entityManager,应该在不同的方法上使用@PostConstruct注释。但是这是什么原因呢?