spring-java-config

Spring Batch Table Prefix when using Java Config

折月煮酒 提交于 2019-12-01 03:24:37
问题 My Spring Batch repository (deployed on an Oracle database) lies in a different schema such that I need to prepend the schema name. When using XML configuration, this would be easy to do: <job-repository id="jobRepository" table-prefix="GFA.BATCH_" /> However, as I use Java Config, this turns out to be more tricky. The best solution I found is to have my Java Config class extend DefaultBatchConfigurer and override the createJobRepository() method: @Configuration @EnableBatchProcessing public

AuthenticationCredentialsNotFoundException: An Authentication object was not found in the Security Context

独自空忆成欢 提交于 2019-12-01 02:22:53
问题 I get the below error when I try to send JSON payload from POSTMAN plugin of chrome browser to controller exposed as REST URL - http://localhost:8080/services/acc/create SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/services] threw exception [Request processing failed; nested exception is org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext] with root cause org

How do I define http "security = 'none' in JavaConfig?

一个人想着一个人 提交于 2019-12-01 01:32:49
问题 I want to define something similar to this XML in Spring Boot using Java Config. <http pattern="/webservices/**" security="none"/> I need a different way of securing them and cannot do form-logins. Securing them will come later. For now, I want to stop securing them with http.formLogin(). I have overridden WebSecurityConfigurerAdapter.configure() as such. I cannot find an API to say, like this: http.securityNone().antMatchers("/webservices") Here is my configure() method now: @Override

Spring Java Config: Tomcat deploy without web.xml

久未见 提交于 2019-11-30 19:48:59
I built a java configured Spring MVC application without any XML. I can deploy and start the application on my laptop without any problems. But as soon as I try to deploy my application on my testserver (tomcat 7), I receive following message: HTTP Status 404 - The requested resource (/[application context]/) is not available. I build my applications using the Eclipse Maven plugin. Is it possible to deploy the application without the web.xml and if not, which is the basic web.xml I really need? Maven WAR Plugin: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin<

How to redirect HTTP requests to HTTPS using Spring Security Java configuration?

亡梦爱人 提交于 2019-11-30 09:12:40
I have a Spring Security version 3.2.3 application that listens to both HTTP and HTTPS. I want any request to the HTTP port to be redirected to HTTPS. How do I configure that using Java only? Spring Security javadoc for HttpSecurity proposes the following solution (trimmed to the essential): public class WebSecurityConfig extends WebSecurityConfigurerAdapter { protected void configure(HttpSecurity http) { http.channelSecurity().anyRequest().requiresSecure(); } } However that doesn't work because HttpSecurity doesn't have method channelSecurity() . Replacing channelSecurity() with

Custom Authentication provider with Spring Security and Java Config

ぃ、小莉子 提交于 2019-11-30 06:37:00
问题 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. 回答1: The following does what you need ( CustomAuthenticationProvider is your implementation which needs to be managed by Spring) @Configuration @EnableWebMvcSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private CustomAuthenticationProvider customAuthenticationProvider; @Override

Spring Security Java Config for Siteminder

六眼飞鱼酱① 提交于 2019-11-30 05:40:05
I have an inMemoryAuthentication configuration that works: @Configuration @EnableWebMvcSecurity public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure( AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { authenticationManagerBuilder // .inMemoryAuthentication() // .withUser("employee") // .password("employee") // .roles("RoleEmployee") ; } @Override public void configure(WebSecurity webSecurity) throws Exception { webSecurity.ignoring().antMatchers("/resources/**"); } @Override protected void configure

Spring Java Config: Tomcat deploy without web.xml

我怕爱的太早我们不能终老 提交于 2019-11-30 04:23:13
问题 I built a java configured Spring MVC application without any XML. I can deploy and start the application on my laptop without any problems. But as soon as I try to deploy my application on my testserver (tomcat 7), I receive following message: HTTP Status 404 - The requested resource (/[application context]/) is not available. I build my applications using the Eclipse Maven plugin. Is it possible to deploy the application without the web.xml and if not, which is the basic web.xml I really

@Autowired return exception on UserDetails in Spring-security

荒凉一梦 提交于 2019-11-30 00:34:18
问题 Please show me where I have problem? Here is my project: https://github.com/intrade/inventory I try to enable Spring security using java config and when I try to inject a dependency of type MyCustomUserDetailsService into my SecurityConfig class i get an exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityConfig': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could

How to set UTF-8 character encoding in Spring boot?

孤街醉人 提交于 2019-11-29 18:48:37
问题 I use spring-boot in my project, and I run this jar file which is built by spring-boot as a service on Centos. When I run this service: service myApp start I always get the below error messages: 2016-08-26 09:11:02.002 ERROR 31900 --- [ main] o.s.b.c.FileEncodingApplicationListener : System property 'file.encoding' is currently 'ANSI_X3.4-1968'. It should be 'UTF-8' (as defined in 'spring.mandatoryFileEncoding'). 2016-08-26 09:11:02.018 ERROR 31900 --- [ main] o.s.b.c