spring-java-config

What is right way to supply initialization for log4j2 in a Spring MVC Webapp using Java Config and no web.xml?

一笑奈何 提交于 2019-12-24 03:28:04
问题 I have a Spring MVC Web App (4.0) with log4j2. This webapp uses no web.xml and takes care of configuration through Java Config. Log4j2 configuration needs to take place in an external config file, not on the classpath. In a previous incarnation with web.xml we had <context-param> <param-name>log4jConfiguration</param-name> <param-value>file:///path/to/log4j2.xml</param-value> </context-param> and this worked. In the new web.xml-less world, I tried this: public class WebappInitializer extends

Creating a 'decider-step-loop' with spring-java-config

做~自己de王妃 提交于 2019-12-24 02:21:07
问题 I'm trying to port a spring-batch job, which is defined in xml to a java-config based job. This is a snippet of my job-configuration-file: <decision id="decision" decider="someDecider"> <next on="continue" to="stepCont" /> <next on="timeout" to="stepTimeout" /> <end on="COMPLETED" /> </decision> <step id="stepCont" next="stepReport"> ... do something </step> <step id="stepReport" next="decision"> ... create report </step> <step id="stepTimeout"> ... </step> Is there a way to create such a

How to create a bean after ServletContext initialized in Spring Boot?

风格不统一 提交于 2019-12-23 13:07:53
问题 I have a bean, which implements ServletContextAware and BeanFactoryPostProcessor interfaces. I need this this bean register into the applicationContext after the ServletContext finished initialization, because I use some parameters in the servletContext to init this bean. I am using the Spring Boot, the bean name is SpringBeanProcessorServletAware. I have add it into a configuration bean. @Bean public static SpringBeanProcessorServletAware springBeanProcessor() {

Spring Security Configuration in Spring Boot

我只是一个虾纸丫 提交于 2019-12-23 10:08:55
问题 I am working on converting a Spring 3 project to Spring 4 + Spring Boot . I don't know whether it is a right thing to do or not yet. I convert the Spring Security XML configuration to a Java based configuration as the following: @Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().antMatchers("/", "/home").permitAll() .anyRequest().authenticated(

How to register multiple beans using single @Bean-annotated method (or similar) in Spring?

家住魔仙堡 提交于 2019-12-23 07:26:56
问题 I have a class similar to the following: @Configuration public class ApplicationConfiguration { private <T> T createService(Class<T> serviceInterface) { // implementation omitted } @Bean public FooService fooService() { return createService(FooService.class); } @Bean public BarService barService() { return createService(BarService.class); } ... } The problem is that there are too many @Bean-annotated methods which differ only in their names, return types and arguments for the crateService

quartz Fire Job immediately doesn't work

谁都会走 提交于 2019-12-22 18:01:33
问题 I integrated quartz 2 and spring 4 with maven and java annotation ( using servlet 3 ), also i am using tomcat 7 maven plugin for deploying my project,my quartz Configuration class like as below : and my job class define simply like as below : then i use the quartz Scheduler for using fire my job trigger immediately as below : but my problem is : when i call fireNow methode with "job1" , "mygroup" parameters nothing happens and my job1 do not call immediately and don't print anything in

Adding spring security to embedded Jetty

一曲冷凌霜 提交于 2019-12-22 11:05:04
问题 I am trying to add Spring Security - OAuth2 to my Rest API which resides on embedded Jetty. I am getting "No bean named 'springSecurityFilterChain' is defined" error. When I add a ContextLoadListener with context.addEventListener( new ContextLoaderListener() ); I start getting Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!" error. The following is the structure of my Code

Single Sign Out with Spring Security and CAS

 ̄綄美尐妖づ 提交于 2019-12-21 12:57:56
问题 Using pure Spring Java Config I'm having troubles getting Spring and CAS to perform Single Sign Out. I have Single Sign On working with the configuration below. I use a simple JSP page to do a form POST to the url https://nginx.shane.com/app/logout and I include the CSRF value in the POST'd data. It all appears to work with no errors but when I go to a secured page it just lets me back in without requiring to login. Any ideas? @Configuration @EnableWebSecurity public class

Single Sign Out with Spring Security and CAS

孤街浪徒 提交于 2019-12-21 12:57:47
问题 Using pure Spring Java Config I'm having troubles getting Spring and CAS to perform Single Sign Out. I have Single Sign On working with the configuration below. I use a simple JSP page to do a form POST to the url https://nginx.shane.com/app/logout and I include the CSRF value in the POST'd data. It all appears to work with no errors but when I go to a secured page it just lets me back in without requiring to login. Any ideas? @Configuration @EnableWebSecurity public class

Spring Security Java Config - custom AuthenticationProvider and UserDetailsService

血红的双手。 提交于 2019-12-20 20:44:41
问题 I use java configuration to configure Spring Security, and I have customized AuthenticationProvider and customized UserDetailsService, to add extra login field following http://forum.spring.io/forum/spring-projects/security/95715-extra-login-fields I have difficulty to add both of the customized Classes into Spring Security framework by using java configuration. As java doc of AuthenticationProvider#authenticationProvider describes: Add authentication based upon the custom