Questions tagged [spring-java-config]

Spring Java Configuration (JavaConfig) provides a pure-Java means of configuring the Spring IoC container. By taking advantage of Java 5.0 language features such as annotations and generics, JavaConfig allows users to express configuration logic and metadata directly in code, alleviating any need for XML.

Guides:

Video tutorial on Spring Framework

Blog:

Related tags

More information:

636 questions
179
votes
9 answers

Spring Java Config: how do you create a prototype-scoped @Bean with runtime arguments?

Using Spring's Java Config, I need to acquire/instantiate a prototype-scoped bean with constructor arguments that are only obtainable at runtime. Consider the following code example (simplified for brevity): @Autowired private ApplicationContext…
Les Hazlewood
  • 18,480
  • 13
  • 68
  • 76
93
votes
3 answers

How To Inject AuthenticationManager using Java Configuration in a Custom Filter

I'm using Spring Security 3.2 and Spring 4.0.1 I'm working on converting an xml config into a Java config. When I annotate AuthenticationManager with @Autowired in my Filter, I'm getting an exception Caused by:…
rince
  • 1,988
  • 1
  • 20
  • 24
84
votes
14 answers

disabling spring security in spring boot app

I have a spring boot web app with spring security configured. I want to disable authentication for a while (until needed). I add this to the application.properties: security.basic.enable: false management.security.enabled: false Here is some…
jayjaypg22
  • 1,641
  • 5
  • 22
  • 41
54
votes
14 answers

PreAuthorize not working on Controller

I'm trying to define access rules at method-level but it's not working what so ever. SecurityConfiguration @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class SecurityConfiguration extends…
prettyvoid
  • 3,446
  • 6
  • 36
  • 60
48
votes
7 answers

How to java-configure separate datasources for spring batch data and business data? Should I even do it?

My main job does only read operations and the other one does some writing but on MyISAM engine which ignores transactions, so I wouldn't require necessarily transaction support. How can I configure Spring Batch to have its own datasource for the…
amacoder
  • 791
  • 2
  • 7
  • 11
36
votes
6 answers

CharacterEncodingFilter don't work together with Spring Security 3.2.0

I'm new to Spring MVC framework and I have got an issue that I can not resolve by myself. Everything started when I integrated spring security with my application, after that all unicode values from HTML form were not encoded (spring security works…
ajurasz
  • 716
  • 1
  • 8
  • 9
35
votes
7 answers

Failed to Load ApplicationContext during Spring unit test

I am trying to run a Junit functional test using Springs java-config for my application context. I am not sure if it is a problem with Spring or Junit... just not sure.. The application runs fine on my local server (hitting the db), but when I try…
Prancer
  • 3,336
  • 2
  • 32
  • 38
33
votes
2 answers

In Spring-Security with Java Config, why does httpBasic POST want csrf token?

I am using Spring-Security 3.2.0.RC2 with Java config. I set up a simple HttpSecurity config that asks for basic auth on /v1/**. GET requests work but POST requests fail with: HTTP Status 403 - Invalid CSRF Token 'null' was found on the request…
30
votes
3 answers

How to represent the Spring Security "custom-filter" using Java configuration?

What is the equivalent Java configuration for the Spring Security tag? I tried http.addFilter( new MyUsernamePasswordAuthenticationFilter() ) where the…
user3722706
  • 301
  • 1
  • 3
  • 4
23
votes
1 answer

Spring security oauth2 and form login configuration

My project consists exposes two different parts, a JSF admin panel and a RESTfull service. I am trying to setup spring security to use different authentication methods depending on the URL the user navigates. The requirements are Users navigating…
maxsap
  • 2,971
  • 9
  • 44
  • 70
23
votes
6 answers

Disable Basic Authentication while using Spring Security Java configuration

I am trying to secure a web application using Spring Security java configuration. This is how the configuration looks:- @Configuration @EnableWebMvcSecurity public class SecurityConfiguration extends WebSecurityConfigurerAdapter { private…
Kumar Sambhav
  • 7,503
  • 15
  • 63
  • 86
22
votes
8 answers

How do I remove the ROLE_ prefix from Spring Security with JavaConfig?

I'm trying to remove the "ROLE_" prefix in Spring Security. The first thing I tried was: http.servletApi().rolePrefix(""); That didn't work, so I tried creating a BeanPostProcessor as suggested in…
Matt Raible
  • 8,187
  • 9
  • 61
  • 120
21
votes
1 answer

Difference between Spring configuration inheritance and @Import

what is the difference between @Configuration class ConfigA extends ConfigB { //Some bean definitions here } and @Configuration @Import({ConfigB.class}) class ConfigA { //Some bean definitions here } And also if we are importing multiple…
Shishya
  • 1,069
  • 1
  • 14
  • 22
21
votes
2 answers

Custom Authentication provider with Spring Security and Java Config

How can I define a custom Authentication provider by using Spring Security with Java Configurations? I would like to perform a login checking credentials on my own database.
vdenotaris
  • 13,297
  • 26
  • 81
  • 132
21
votes
2 answers

Weblogic datasource disappears from JNDI tree

We are using weblogic version 12C. Steps to reproduce the issue: - Create the datasource. Deploy the application to weblogic. Application works fine. Update the deployed ear with the new one. Application is not able to connect the…
mittalpraveen
  • 481
  • 3
  • 13
1
2 3
42 43