hibernate,spring-mvc,hsqldb,spring-boot,spring-java-config
@RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = {MvcConfig.class,SecurityConfig.class}) @WebAppConfiguration These 3 lines make no sense what so ever on your configuration class. It should instead be annotated with @Configuration and those 3 lines should be on your test class. @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = TestApplicationContext.class) @WebAppConfiguration public class ApplicationIntegrationTest { … } This is also explained...
spring,spring-boot,spring-java-config
In an embedded container I don't think those properties in web.xml have any meaning, so you should be good to go. Spring Boot does not process WebApplicationInitializers (for example).
java,spring,spring-java-config
Actually it will only create one instance of repository. Using s3Repository() in your @Bean annotated method doesn't really call that method, but just tells the spring to inject the already created bean of type (as implied by return type of method) to the LevelMapper and ImageDownloader bean you create. So...
java,spring,autowired,spring-boot,spring-java-config
One of your DataSources has to be @Primary (see docs).
java,spring,spring-mvc,spring-java-config
You are asking for advices, but it is not far from opinions. This answer is what I have understood of Spring philosophia. Spring allows to use different contextes for the non MVC part and the MVC part and advises to do so, because separation of concerns (*) is considered as...
The parsing phase for a @Configuration class involves reading its class definition, populating a collection of Configuration objects (because one @Configuration class may @Import another @Configuration class so these imports are parsed as well), processing @PropertySources, @ImportResources etc. Processing @PropertySources doesn't, also, load those properties yet. After the parsing phase...
spring-mvc,log4j2,spring-java-config
I believe you can reconfigure log4j2 to a new config file during runtime like this. LoggerContext context = (LoggerContext)LogManager.getContext(false); context.setConfigLocation(URI.create("path to file")); context.reconfigure(); Could just add this to your onStartup....
java,spring,spring-mvc,spring-boot,spring-java-config
OK! Found the problem. This link helped me: https://samerabdelkafi.wordpress.com/2014/08/03/spring-mvc-full-java-based-config/ More specifically this configuration: @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { configurer.enable(); } By setting a default handler, I would no longer get a white page but instead the JSP code as html, which clearly tells me that the JSP was being...
spring-mvc,spring-security,spring-java-config
Your domains localhost and 192.168.1.206are considered to be different origins, and you cant send ajax request from different origins without additional setup. For enabling cross origin requests in Spring MVC you should add a filter that will explicitely allow request origins, by applying the proper headers in the response, an...
spring-security,spring-java-config
The solution is to mimic the good old namespace way of having multiple <http ...> blocks. With Java configuration, you can also have multiple classes extending WebSecurityConfigurerAdapter. Spring Security Reference Manual has an example for that. Extracts : @EnableWebSecurity public class MultiHttpSecurityConfig { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) { 1...
java,spring,spring-mvc,servlets,spring-java-config
Looks like you need this: ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", dispatcherServlet); dispatcher.setLoadOnStartup(1); dispatcher.addMapping("/*"); dispatcher.setMultipartConfig(new MultipartConfigElement("/tmp", 1024*1024*5, 1024*1024*5*5, 1024*1024)); ...
spring-integration,spring-java-config
H-m... Looks like. It is really a bug in the DslRecipientListRouter logic: https://github.com/spring-projects/spring-integration-java-dsl/issues/9 Will be fixed soon and released over a couple of days. Thank you for pointing that out! BTW. your logic isn't correct a bit: Even when we fix that RecipientListRouter, the second recipinet will receive the same...
I solved this problem by removing the @Resource annotations from the Java configuration file: public class UserBackgroundProcessorConfiguration implements AsyncConfigurer { @Bean(name="backgroundProcessor") public BackgroundProcessor getBackgroundProcessor() { BackgroundProcessor backgroundProcess = new BackgroundProcessor(); return backgroundProcess; } @Override @Bean(name="executor") public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(10);...
spring,spring-security,spring-java-config,jhipster
Take a look here https://github.com/spring-projects/spring-data-examples/tree/master/rest/security which has http .httpBasic().and() .authorizeRequests() .antMatchers(HttpMethod.POST, "/employees").hasRole("ADMIN") .antMatchers(HttpMethod.PUT, "/employees/**").hasRole("ADMIN") .antMatchers(HttpMethod.PATCH, "/employees/**").hasRole("ADMIN").and() .csrf().disable(); ...
active-directory,spring-ldap,spring-java-config,spring-security-ldap
For what I can tell you can achieve this via the DefaultLdapAuthoritiesPopulator, it has a setIgnorePartialResultException(boolean) method to achieve exactly this. So in your config class you would need to do something along the following lines: @Bean public LdapAuthoritiesPopulator ldapAuthoritiesPopulator() throws Exception { DefaultLdapAuthoritiesPopulator populator = new DefaultLdapAuthoritiesPopulator(contextSource(), "dc=<company>,dc=local"); populator.setIgnorePartialResultException(true);...
java,spring,spring-mvc,spring-java-config
Mahesh C. showed the right path, but his implementation is too limited. He is right on one point : you cannot use directly AbstractAnnotationConfigDispatcherServletInitializer for multiple dispatcher servlet. But the implementation should : create a root application context gives it an initial configuration and say what packages it should scan...
java,spring,spring-java-config
Maybe you could reference it with separation by Qualifier: @Bean @Qualifier("complexBeanParam") public ComplexBean complexBeanByParameters(List<BasicBean> basicBeans) { return new ComplexBean(basicBeans); } @Bean @Qualifier("complexBeanRef") public ComplexBean complexBeanByReferences() { return new ComplexBean(Arrays.asList(basicBean1(), basicBean2())); } and for example autowire: @Autowired @Qualifier("complexBeanParam") private ComplexBean beanParam; ...
spring-security,spring-java-config
I removed this bean definition from the security configuration and it seems to have solved the issue @Bean public DelegatingFilterProxy springSecurityFilterChain() { DelegatingFilterProxy filterProxy = new DelegatingFilterProxy(); return filterProxy; } ...
The proper configuration is here @Configuration @Order(3) @ImportResource({ "classpath:META-INF/cxf/cxf.xml" }) public class CXFConfiguration { @Autowired Bus cxfBus; @Bean public Endpoint lotServiceEndpointWS() { EndpointImpl endpoint = new EndpointImpl(this.cxfBus, new LotServiceEndpoint()); endpoint.setAddress("/LotService"); endpoint.publish(); return endpoint; } ...
spring,aop,spring-java-config,spring-aspects
Finally I sorted it out using @Lazyon services (with methods annotated with @Async), and also, where they were autowired. This way I guess Spring only initialize and autowires those services when they're required instead of on application context initialization.
spring-mvc,spring-boot,thymeleaf,spring-java-config,apache-tiles
Okay guys, I got it and I hope it helps for other developers with similar problems. In POM I removed all Spring-Dependencies and I use only Spring-Starter-Dependencies like following snippet: ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!-- Apache Tiles -->...
java,spring,dependency-injection,inversion-of-control,spring-java-config
As JdbcTemplate contains JdbcTemplate(DataSource dataSource) constructor. You can try this way @PropertySource("classpath:jdbc.properties") @Configuration public class Config { @Autowired private Environment env; @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } @Bean(name = "dataSource") public DataSource dataSource() { BasicDataSource datasource = new BasicDataSource();...
spring,spring-integration,spring-java-config
The @IdempotentReceiver on the @Bean level is parsed by the IdempotentReceiverAutoProxyCreatorInitializer. We have a test-case on the matter - IdempotentReceiverIntegrationTests. From other side: how do you want to be sure that it works as expected? Show, please, your myService() content. For any AbstractMessageProducingHandler the outputChannel must be specified as the...
spring,spring-mvc,spring-security,spring-java-config
Your first question's answer-> (1) You can create CustomAuthenticationFailureHandler by extending AuthenticationFailureHandler class. (2) in CustomAuthenticationFailureHandler's onAuthenticationFailure method, write this code: @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { saveException(request, exception); redirectStrategy.sendRedirect(request, response, request.getHeader("referer")); } (3) In your...
java,spring,spring-integration,spring-java-config
Your config looks good, but you should know in addition that any Spring Integration Consumer component consists of two main objects: MessageHandler (TcpOutboundGateway in your case) and EventDrivenConsumer for subscriable input-channel or PollingConsumer if input-channel is Pollable. So, since you already have the first, handling, part you need another consuming....
spring-security,spring-java-config
I could fix the security with the following configuration: @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().withUser("stephane").password("mypassword").roles("ADMIN"); } @Override protected void configure(HttpSecurity http) throws Exception { http .csrf().disable() .httpBasic() .authenticationEntryPoint(restAuthenticationEntryPoint) .and() .authorizeRequests() .antMatchers("/**").hasRole("ADMIN") .anyRequest().authenticated(); } I was missing the...
spring-security,spring-java-config
The problem is that you create a new instance of WebtoolAuthenticationProvider with new. Autowire doesn't work then. Adjust your WebtoolSecurityConfig: @Autowired private WebtoolAuthenticationProvider authenticationProvider; @Autowired public void registerGlobalAuthentication(AuthenticationManagerBuilder auth) throws Exception { auth.authenticationProvider(authenticationProvider); } ...
java,spring,hibernate,spring-java-config
Don't think that you'll need to mention the factory bean or methods in the java config.In your class wire the sessionFactory in class and see if it works @Component public class SchemaExportListener extends AbstractEnvironment implements ApplicationListener<ContextRefreshedEvent> { @Autowired private LocalSessionFactoryBean localSessionFactoryBean; @Override public void onApplicationEvent(ContextRefreshedEvent event) { log.debug("onApplicationEvent"); if (isPrintSchemaEnabled())...
java,xml,spring,spring-java-config
1.PropertyPlaceholderConfigurer @Configuration @PropertySource(value = "spring/test5.properties") class Config { @Bean PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer(); c.setIgnoreUnresolvablePlaceholders(true); return c; } ... OOzieJobFactory class Config { @Bean @Scope("prototype") CmdArgs cmdArgs() { return new CmdArgs(); } @Bean @Scope("prototype") OozieJobFactory oozieJobFactory() { return new OozieJobFactory(); } @Bean...
spring-security,spring-java-config
You got the postprocessor on the wrong object. Please rewrite the post processor with the following .anyRequest().authenticated().withObjectPostProcessor(new ObjectPostProcessor<FilterSecurityInterceptor>() { public <O extends FilterSecurityInterceptor> O postProcess( O fsi) { FilterInvocationSecurityMetadataSource newSource = new MyFilterSecurityMetadataSource(); fsi.setSecurityMetadataSource(newSource); return fsi; } }) ...
java,spring,configuration,spring-security,spring-java-config
By default POST request is required to the logout url. To perform logout on GET request you need: http .logout() .logoutRequestMatcher(new AntPathRequestMatcher("/logout")); See the Docs: http://docs.spring.io/spring-security/site/docs/3.2.4.RELEASE/reference/htmlsingle/ (section 6.5.3. Logging Out)...
Below should be all you need. Notice that I have injected your Hello bean as a method parameter. Spring DI shall take care of the rest. @Configuration @Import(A.class) public class B{ @Bean(name="greeting") public greeting(Hello hello){ return new Greeting(hello); } ...
spring,spring-data-jpa,spring-java-config
Add the following to your configuration: @Bean public EclipseLinkJpaDialect eclipseLinkJpaDialect() { return new EclipseLinkJpaDialect(); } ...
spring,configuration,spring-java-config
I guess you are missing annotation-config in your xml. Include the below in your appcontext.xml. This is required to process your annotation. Thanks. <context:annotation-config/> ...
spring,spring-aop,spring-java-config,spring-aspects
Tricky. Asynchronous behavior is added through proxying. Spring provides you with a proxy that wraps the actual object and performs the actual invocation in a separate thread. It looks something like this (except most of this is done dynamically with CGLIB or JDK proxies and Spring handlers) class ProxyListener extends...
java,spring,spring-integration,spring-java-config
The TcpSendingMessageHandler is for one-way usage - just for sending messages to the TCP socket. So, your config looks good and seems for me it should work. TcpListener exiting - no listener and not single use Is just DEBUG message from the TcpNetConnection which indicates that your component is one-way....
spring,apache-camel,spring-java-config
Looks like if you want to use BridgePropertyPlaceholderConfigurer, you need to instantiate Camel contexts with CamelContextFactoryBean. It has initPropertyPlaceholder method: @Override protected void initPropertyPlaceholder() throws Exception { super.initPropertyPlaceholder(); Map<String, BridgePropertyPlaceholderConfigurer> beans = applicationContext.getBeansOfType(BridgePropertyPlaceholderConfigurer.class); if (beans.size() == 1) { // setup properties component that uses this beans BridgePropertyPlaceholderConfigurer configurer =...
spring,spring-mvc,spring-java-config
I have just found the answer. While using the WebMvcConfigurationSupport, we need to remove the annotation @EnableWebMvc
spring,spring-batch,spring-java-config
Reading can be done from a different datasource without problems because reading is unrelated respect to where SB metadata are saved. Extracted from JdbcCustomItemReader javadoc: By default the cursor will be opened using a separate connection which means that it will not participate in any transactions created as part of...
java,spring,login,spring-security,spring-java-config
You can use the defaultSuccessUrl and failureUrl on both the .formLogin() and .logout functions. Here is an example: .formLogin() .loginPage("/login").loginProcessingUrl("/login/validate") .defaultSuccessUrl("/").failureUrl("/login?error=true") .usernameParameter("username").passwordParameter("password") .and() .logout() .logoutRequestMatcher(new AntPathRequestMatcher("/logout")) .logoutSuccessUrl("/login?logout=true") As far as a redirect for each user role, I would suggest the defaultSuccessUrl page have redirects based on the user's role:...
spring,spring-data,spring-java-config
This is very likely to be caused by using an older version of Spring Data JPA. When using 1.4.2 you should pull in Spring Data Commons 1.7.2 and thus benefit from a few improvements we made in the area of type prediction. Bottom line is: this should work in the...
spring-mvc,http-status-code-404,wildfly-8,spring-java-config
https://jira.spring.io/browse/SPR-12555 Its seems spring mvc works as designed, server wont recognize WebApplicationInitializer if spring-web.jar is not inside WEB-INF/lib. Possible solutions are discussed in the jira link above
spring,spring-mvc,spring-security,spring-java-config
RE-EDIT: Based on the comment provided i can see the problem would be with your following piece of code: .and() .logout().logoutUrl("/") Based on that code setup it means every time you go to your homepage/index page it will return http:///login?logout as per your problem. I'm going to assume that you...
java,spring,spring-data,spring-boot,spring-java-config
You might need to use Spring Boot's @EntityScan annotation if your JPA entities are not in a sub-package of com.example.configuration. I would also recommend that you move your @Configuration off the SpringBootServletInitializer and into its own class. If you can move your configuration class up a level you can drop...
spring,email,spring-java-config
The code you posted (along with some small improvements to make it more configurable) would be transformed into the following Java config: @Configuration public class MailConfig { @Value("${email.host}") private String host; @Value("${email.from}") private String from; @Value("${email.subject}") private String subject; @Bean public JavaMailSender javaMailService() { JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); javaMailSender.setHost(host);...
spring-security,spring-boot,spring-java-config
Ultimately, it turns out that if you are overriding the UsernamePasswordAuthenticationFilter, Provider and Token, you need to go back to XML configuration. It seems that Spring Security does not properly publish the overridden vanilla spring SecurityFilterChain as a bean, so this is what you get the vanilla version back no...
spring,spring-integration,spring-java-config
See this answer. Since version 4.0 any MessageHandler can be configured using @ServiceActivator. In this case, the handler is a FileTransferringMessageHandler and it needs to be configured with an appropriately configured FtpRemoteFileTemplate. Which needs a session factory. pickupChannel would be a DirectChannel. EDIT: You should also take a look a...
spring,spring-security,oauth-2.0,spring-java-config
I tried to adapt your security configuration. Unfortunately, I can not validate this configuration due to missing reference application. Maybe it can help you: @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UserRepository userRepository; @Autowired private PasswordEncoder passwordEncoder; @Autowired protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(new UserDetailsService()...
spring,jasypt,spring-java-config
Judging by the source code of jasypt library (EncryptionNamespaceHandler and EncryptorFactoryBean) and the API for PooledPBEStringEncryptor I'm assuming you can start experimenting with something like this: @Bean public EnvironmentStringPBEConfig environmentVariablesConfiguration() { EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig(); config.setAlgorithm("PBEWithMD5AndDES"); config.setPasswordEnvName("APP_ENCRYPTION_PASSWORD"); return config; } @Bean public PooledPBEStringEncryptor stringEncryptor() {...
java,spring,spring-java-config
According to docs in http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/aop.html @Configuration @EnableSpringConfigured public class AppConfig { } Is the substitute of: <context:spring-configured/>...