spring-java-config

How to do filter mapping in AbstractAnnotationConfigDispatcherServletInitializer Spring

寵の児 提交于 2019-12-12 10:38:10
问题 Here is the problem: I can successfully register the Filter, but don't know how to set the mapping URL using this specific configuration. Here is my Class: public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { return new Class<?>[]{AppConfig.class}; } @Override protected Class<?>[] getServletConfigClasses() { return new Class<?>[]{WebConfig.class}; } @Override protected Filter[] getServletFilters() {

@EnableJpaRepositories looking for which package?

主宰稳场 提交于 2019-12-12 09:47:36
问题 I am learning how to build JSF and Spring integrated webapp. I am using java config to configure. The problem is @EnableJpaRepositories, which package should I put in this annotation? the package contains entity classes? or configuration class? or? and can I just put my root package into it and let it search by itself? 回答1: EnableJpaRepositories - use only for repositories and not for entity or config. Main goal for this annotation is to find all repositories. you can configure jpa

Spring Security with Java Configuration: How to handle BadCredentialsException from a custom provider

跟風遠走 提交于 2019-12-12 08:15:44
问题 I need to authenticate some rest services using a token id in the url (or maybe in the request header - but this is not important for now). I am trying to use java configuration to set this up using as a guide this post. My problem is that I do not know how to handle "BadCredentialsException" that is thrown when the authentication fails from the provider. Here is my Security Config: public static class SecurityConfigForRS extends WebSecurityConfigurerAdapter { @Autowired

No bean named 'springSecurityFilterChain' is defined error in spring java based config

删除回忆录丶 提交于 2019-12-12 03:39:09
问题 Here is the error log. org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter springSecurityFilterChain org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory

how to do spring javaconfig inheritance

非 Y 不嫁゛ 提交于 2019-12-11 16:51:57
问题 How do I make a javaconfig version for the below? <bean id="parentDao" class="com.MyHibernateDao"> <property name="sessionFactory" ref="mySessionFactory" /> </bean> <bean id="childDao" class="com.ChildHibernateImpl" parent="parentDao"/> (btw, Is there any documentation for Spring Javaconfig?) Regards, j 回答1: As far as I have researched, there is no templating way that is similar to the XML sample shown, where the 'parent' attribute is used. 来源: https://stackoverflow.com/questions/28927089/how

CXF Servlet Java config redirect to index.html

冷暖自知 提交于 2019-12-11 12:38:50
问题 I'm trying to configure CXF entirely through java config, everything is working fine except the static-welcome-file init parameter. Here is my code: @Bean public ServletRegistrationBean cxfServlet() { ServletRegistrationBean registrationBean = new ServletRegistrationBean(new CXFServlet(),"/service/*"); registrationBean.setLoadOnStartup(1); //Allows static resources to be returned Map<String, String> initParams = new HashMap<>(); initParams.put("static-resources-list", "/app/.*"); initParams

Issue with @ComponentScan, filters since migrating to javaconfig

强颜欢笑 提交于 2019-12-11 11:14:57
问题 I am trying to migrate to javaConfig using the following configuration: WebMvcConfig : @Configuration @EnableWebMvc @ComponentScan(basePackages = { "com.bignibou" }, useDefaultFilters = false, includeFilters = { @Filter(type = FilterType.ANNOTATION, value = Controller.class), @Filter(type = FilterType.ANNOTATION, value = ControllerAdvice.class) }) public class WebMvcConfig extends WebMvcConfigurationSupport { @Override public void configureMessageConverters(List<HttpMessageConverter<?>>

Issue with injecting a dependency into a bean itself used by a @Configuration class loaded on startup

前提是你 提交于 2019-12-11 10:45:42
问题 I want for a @Configuration class to manipulate a Map of Spring beans (here the beans will be the values for the Map). Moreover, some Spring beans will have dependencies injected into them - such as Spring Data Jpa repositories. I have the following configuration class (MethodSecurityConfiguration): @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true) public class MethodSecurityConfiguration extends GlobalMethodSecurityConfiguration { @Override protected AuthenticationManager

@Profile cause Unable to start EmbeddedWebApplicationContext

…衆ロ難τιáo~ 提交于 2019-12-11 04:29:39
问题 im trying to use @Profile functionality to separate production/dev environment configuration and 'tests' config. But when I add @Profile to my configuration class I get: Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. at org.springframework.boot

@TestPropertySource not working?

雨燕双飞 提交于 2019-12-11 03:38:14
问题 I am trying to test my Spring Configuration. Here is my config class @Configuration @PropertySource("/etc/my.properties") @ComponentScan("my.package") public class SpringConfig { @Bean ..... } And when I tried to test it thru my test as @RunWith(SpringJUnit4ClassRunner.class) @TestPropertySource(locations = "classpath:test.properties") @ContextConfiguration(classes = {SpringConfigIntTest.class, SpringConfig.class}) public class SpringConfigIntTest { ....... } I keep getting the failure saying