How to use configuration from spring-security.xml in spring boot?











up vote
1
down vote

favorite












I am trying to use my existing spring security xml file in spring boot. I added
@ImportResource to load my existing xml configuration. on console its showing loading spring-security.xml.



I am getting below error:



 "Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.security.servlet.SpringBootWebSecurityConfiguration$DefaultConfigurerAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor<?>' available"

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' in your


OnlineshoppingApplication.java



package net.kzn.onlineshopping;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;

@SpringBootApplication
@ComponentScan(basePackages = {"net.kzn.onlineshopping","net.kzn.shoppingbackend"})
@ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
public class OnlineshoppingApplication {

public static void main(String args) {
SpringApplication.run(OnlineshoppingApplication.class, args);
}


}


spring-security.xml



<beans:beans
xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">

<context:component-scan
base-package="net.kzn.shoppingbackend" />
<beans:bean id="passwordEncoder"
class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>
<http pattern="/resources/**" security="none"/>

<http>
<!-- only admin access -->
<intercept-url pattern="/manage/**" access="hasAuthority('ADMIN')" />
<!-- only user access (who is registered) -->
<intercept-url pattern="/cart/**" access="hasAuthority('USER')" />
<!-- rest of the world -->
<intercept-url pattern="/**" access="permitAll" />
<form-login login-page="/login"/>
<access-denied-handler error-page="/access-denied"/>
</http>

<authentication-manager>
<authentication-provider>
<password-encoder ref="passwordEncoder"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="select email, password, enabled from user_detail where email = ?"
authorities-by-username-query="select email, role from user_detail where email = ?" />
</authentication-provider>
</authentication-manager>

</beans:beans>


my pom.xml file



pom.xml



<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.kzn</groupId>
<artifactId>shoppingbackend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>shoppingbackend</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.webflow/spring-webflow -->
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.5.1.RELEASE</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>


How can i solve this problem?










share|improve this question
























  • can you please share your pom.xml file?
    – GauravRai1512
    Nov 20 at 12:58










  • I added pom.xml file.
    – vidy
    Nov 20 at 13:08










  • i have added an answer please implement and check.First use enablewebsecurity annotation and execute your application if still your issue didn't resolved try to add EnableAutoConfiguration and exclude few class.
    – GauravRai1512
    Nov 20 at 13:10

















up vote
1
down vote

favorite












I am trying to use my existing spring security xml file in spring boot. I added
@ImportResource to load my existing xml configuration. on console its showing loading spring-security.xml.



I am getting below error:



 "Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.security.servlet.SpringBootWebSecurityConfiguration$DefaultConfigurerAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor<?>' available"

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' in your


OnlineshoppingApplication.java



package net.kzn.onlineshopping;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;

@SpringBootApplication
@ComponentScan(basePackages = {"net.kzn.onlineshopping","net.kzn.shoppingbackend"})
@ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
public class OnlineshoppingApplication {

public static void main(String args) {
SpringApplication.run(OnlineshoppingApplication.class, args);
}


}


spring-security.xml



<beans:beans
xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">

<context:component-scan
base-package="net.kzn.shoppingbackend" />
<beans:bean id="passwordEncoder"
class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>
<http pattern="/resources/**" security="none"/>

<http>
<!-- only admin access -->
<intercept-url pattern="/manage/**" access="hasAuthority('ADMIN')" />
<!-- only user access (who is registered) -->
<intercept-url pattern="/cart/**" access="hasAuthority('USER')" />
<!-- rest of the world -->
<intercept-url pattern="/**" access="permitAll" />
<form-login login-page="/login"/>
<access-denied-handler error-page="/access-denied"/>
</http>

<authentication-manager>
<authentication-provider>
<password-encoder ref="passwordEncoder"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="select email, password, enabled from user_detail where email = ?"
authorities-by-username-query="select email, role from user_detail where email = ?" />
</authentication-provider>
</authentication-manager>

</beans:beans>


my pom.xml file



pom.xml



<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.kzn</groupId>
<artifactId>shoppingbackend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>shoppingbackend</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.webflow/spring-webflow -->
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.5.1.RELEASE</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>


How can i solve this problem?










share|improve this question
























  • can you please share your pom.xml file?
    – GauravRai1512
    Nov 20 at 12:58










  • I added pom.xml file.
    – vidy
    Nov 20 at 13:08










  • i have added an answer please implement and check.First use enablewebsecurity annotation and execute your application if still your issue didn't resolved try to add EnableAutoConfiguration and exclude few class.
    – GauravRai1512
    Nov 20 at 13:10















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am trying to use my existing spring security xml file in spring boot. I added
@ImportResource to load my existing xml configuration. on console its showing loading spring-security.xml.



I am getting below error:



 "Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.security.servlet.SpringBootWebSecurityConfiguration$DefaultConfigurerAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor<?>' available"

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' in your


OnlineshoppingApplication.java



package net.kzn.onlineshopping;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;

@SpringBootApplication
@ComponentScan(basePackages = {"net.kzn.onlineshopping","net.kzn.shoppingbackend"})
@ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
public class OnlineshoppingApplication {

public static void main(String args) {
SpringApplication.run(OnlineshoppingApplication.class, args);
}


}


spring-security.xml



<beans:beans
xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">

<context:component-scan
base-package="net.kzn.shoppingbackend" />
<beans:bean id="passwordEncoder"
class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>
<http pattern="/resources/**" security="none"/>

<http>
<!-- only admin access -->
<intercept-url pattern="/manage/**" access="hasAuthority('ADMIN')" />
<!-- only user access (who is registered) -->
<intercept-url pattern="/cart/**" access="hasAuthority('USER')" />
<!-- rest of the world -->
<intercept-url pattern="/**" access="permitAll" />
<form-login login-page="/login"/>
<access-denied-handler error-page="/access-denied"/>
</http>

<authentication-manager>
<authentication-provider>
<password-encoder ref="passwordEncoder"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="select email, password, enabled from user_detail where email = ?"
authorities-by-username-query="select email, role from user_detail where email = ?" />
</authentication-provider>
</authentication-manager>

</beans:beans>


my pom.xml file



pom.xml



<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.kzn</groupId>
<artifactId>shoppingbackend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>shoppingbackend</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.webflow/spring-webflow -->
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.5.1.RELEASE</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>


How can i solve this problem?










share|improve this question















I am trying to use my existing spring security xml file in spring boot. I added
@ImportResource to load my existing xml configuration. on console its showing loading spring-security.xml.



I am getting below error:



 "Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.security.servlet.SpringBootWebSecurityConfiguration$DefaultConfigurerAdapter': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor<?>' available"

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor' in your


OnlineshoppingApplication.java



package net.kzn.onlineshopping;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;

@SpringBootApplication
@ComponentScan(basePackages = {"net.kzn.onlineshopping","net.kzn.shoppingbackend"})
@ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
public class OnlineshoppingApplication {

public static void main(String args) {
SpringApplication.run(OnlineshoppingApplication.class, args);
}


}


spring-security.xml



<beans:beans
xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">

<context:component-scan
base-package="net.kzn.shoppingbackend" />
<beans:bean id="passwordEncoder"
class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>
<http pattern="/resources/**" security="none"/>

<http>
<!-- only admin access -->
<intercept-url pattern="/manage/**" access="hasAuthority('ADMIN')" />
<!-- only user access (who is registered) -->
<intercept-url pattern="/cart/**" access="hasAuthority('USER')" />
<!-- rest of the world -->
<intercept-url pattern="/**" access="permitAll" />
<form-login login-page="/login"/>
<access-denied-handler error-page="/access-denied"/>
</http>

<authentication-manager>
<authentication-provider>
<password-encoder ref="passwordEncoder"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="select email, password, enabled from user_detail where email = ?"
authorities-by-username-query="select email, role from user_detail where email = ?" />
</authentication-provider>
</authentication-manager>

</beans:beans>


my pom.xml file



pom.xml



<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.kzn</groupId>
<artifactId>shoppingbackend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>shoppingbackend</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.webflow/spring-webflow -->
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.5.1.RELEASE</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>


How can i solve this problem?







java spring spring-boot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 13:07

























asked Nov 20 at 12:39









vidy

376113




376113












  • can you please share your pom.xml file?
    – GauravRai1512
    Nov 20 at 12:58










  • I added pom.xml file.
    – vidy
    Nov 20 at 13:08










  • i have added an answer please implement and check.First use enablewebsecurity annotation and execute your application if still your issue didn't resolved try to add EnableAutoConfiguration and exclude few class.
    – GauravRai1512
    Nov 20 at 13:10




















  • can you please share your pom.xml file?
    – GauravRai1512
    Nov 20 at 12:58










  • I added pom.xml file.
    – vidy
    Nov 20 at 13:08










  • i have added an answer please implement and check.First use enablewebsecurity annotation and execute your application if still your issue didn't resolved try to add EnableAutoConfiguration and exclude few class.
    – GauravRai1512
    Nov 20 at 13:10


















can you please share your pom.xml file?
– GauravRai1512
Nov 20 at 12:58




can you please share your pom.xml file?
– GauravRai1512
Nov 20 at 12:58












I added pom.xml file.
– vidy
Nov 20 at 13:08




I added pom.xml file.
– vidy
Nov 20 at 13:08












i have added an answer please implement and check.First use enablewebsecurity annotation and execute your application if still your issue didn't resolved try to add EnableAutoConfiguration and exclude few class.
– GauravRai1512
Nov 20 at 13:10






i have added an answer please implement and check.First use enablewebsecurity annotation and execute your application if still your issue didn't resolved try to add EnableAutoConfiguration and exclude few class.
– GauravRai1512
Nov 20 at 13:10














1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










I would suggest your to please share pom.xml file and also try to use below annotation with springboot application as few things are missing.



depending on your setup, if you get any startup error related to boot autoconfiguration, you might have to exclude some auto-configuration classes, e.g. by putting this onto your Application class:



@EnableAutoConfiguration(exclude = [SecurityFilterAutoConfiguration, SpringBootWebSecurityConfiguration])


also add @EnableWebSecurity annnotation with spring-boot.






share|improve this answer























  • i added @EnableWebSecurity and @EnableAutoConfiguration(exclude = {SecurityFilterAutoConfiguration.class}) and it works for me
    – vidy
    Nov 20 at 13:25












  • but still my webapp is not loading
    – vidy
    Nov 20 at 13:25










  • now which errors you are facing after doing above code? and if my post helps you to fix your current issue so please up vote?
    – GauravRai1512
    Nov 20 at 13:27










  • There are no error on console now but my website is not loading in browser.
    – vidy
    Nov 20 at 13:37










  • is this right way to load dispatcher servlet? @ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
    – vidy
    Nov 20 at 13:38











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393196%2fhow-to-use-configuration-from-spring-security-xml-in-spring-boot%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










I would suggest your to please share pom.xml file and also try to use below annotation with springboot application as few things are missing.



depending on your setup, if you get any startup error related to boot autoconfiguration, you might have to exclude some auto-configuration classes, e.g. by putting this onto your Application class:



@EnableAutoConfiguration(exclude = [SecurityFilterAutoConfiguration, SpringBootWebSecurityConfiguration])


also add @EnableWebSecurity annnotation with spring-boot.






share|improve this answer























  • i added @EnableWebSecurity and @EnableAutoConfiguration(exclude = {SecurityFilterAutoConfiguration.class}) and it works for me
    – vidy
    Nov 20 at 13:25












  • but still my webapp is not loading
    – vidy
    Nov 20 at 13:25










  • now which errors you are facing after doing above code? and if my post helps you to fix your current issue so please up vote?
    – GauravRai1512
    Nov 20 at 13:27










  • There are no error on console now but my website is not loading in browser.
    – vidy
    Nov 20 at 13:37










  • is this right way to load dispatcher servlet? @ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
    – vidy
    Nov 20 at 13:38















up vote
1
down vote



accepted










I would suggest your to please share pom.xml file and also try to use below annotation with springboot application as few things are missing.



depending on your setup, if you get any startup error related to boot autoconfiguration, you might have to exclude some auto-configuration classes, e.g. by putting this onto your Application class:



@EnableAutoConfiguration(exclude = [SecurityFilterAutoConfiguration, SpringBootWebSecurityConfiguration])


also add @EnableWebSecurity annnotation with spring-boot.






share|improve this answer























  • i added @EnableWebSecurity and @EnableAutoConfiguration(exclude = {SecurityFilterAutoConfiguration.class}) and it works for me
    – vidy
    Nov 20 at 13:25












  • but still my webapp is not loading
    – vidy
    Nov 20 at 13:25










  • now which errors you are facing after doing above code? and if my post helps you to fix your current issue so please up vote?
    – GauravRai1512
    Nov 20 at 13:27










  • There are no error on console now but my website is not loading in browser.
    – vidy
    Nov 20 at 13:37










  • is this right way to load dispatcher servlet? @ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
    – vidy
    Nov 20 at 13:38













up vote
1
down vote



accepted







up vote
1
down vote



accepted






I would suggest your to please share pom.xml file and also try to use below annotation with springboot application as few things are missing.



depending on your setup, if you get any startup error related to boot autoconfiguration, you might have to exclude some auto-configuration classes, e.g. by putting this onto your Application class:



@EnableAutoConfiguration(exclude = [SecurityFilterAutoConfiguration, SpringBootWebSecurityConfiguration])


also add @EnableWebSecurity annnotation with spring-boot.






share|improve this answer














I would suggest your to please share pom.xml file and also try to use below annotation with springboot application as few things are missing.



depending on your setup, if you get any startup error related to boot autoconfiguration, you might have to exclude some auto-configuration classes, e.g. by putting this onto your Application class:



@EnableAutoConfiguration(exclude = [SecurityFilterAutoConfiguration, SpringBootWebSecurityConfiguration])


also add @EnableWebSecurity annnotation with spring-boot.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 at 13:09

























answered Nov 20 at 13:03









GauravRai1512

60211




60211












  • i added @EnableWebSecurity and @EnableAutoConfiguration(exclude = {SecurityFilterAutoConfiguration.class}) and it works for me
    – vidy
    Nov 20 at 13:25












  • but still my webapp is not loading
    – vidy
    Nov 20 at 13:25










  • now which errors you are facing after doing above code? and if my post helps you to fix your current issue so please up vote?
    – GauravRai1512
    Nov 20 at 13:27










  • There are no error on console now but my website is not loading in browser.
    – vidy
    Nov 20 at 13:37










  • is this right way to load dispatcher servlet? @ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
    – vidy
    Nov 20 at 13:38


















  • i added @EnableWebSecurity and @EnableAutoConfiguration(exclude = {SecurityFilterAutoConfiguration.class}) and it works for me
    – vidy
    Nov 20 at 13:25












  • but still my webapp is not loading
    – vidy
    Nov 20 at 13:25










  • now which errors you are facing after doing above code? and if my post helps you to fix your current issue so please up vote?
    – GauravRai1512
    Nov 20 at 13:27










  • There are no error on console now but my website is not loading in browser.
    – vidy
    Nov 20 at 13:37










  • is this right way to load dispatcher servlet? @ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
    – vidy
    Nov 20 at 13:38
















i added @EnableWebSecurity and @EnableAutoConfiguration(exclude = {SecurityFilterAutoConfiguration.class}) and it works for me
– vidy
Nov 20 at 13:25






i added @EnableWebSecurity and @EnableAutoConfiguration(exclude = {SecurityFilterAutoConfiguration.class}) and it works for me
– vidy
Nov 20 at 13:25














but still my webapp is not loading
– vidy
Nov 20 at 13:25




but still my webapp is not loading
– vidy
Nov 20 at 13:25












now which errors you are facing after doing above code? and if my post helps you to fix your current issue so please up vote?
– GauravRai1512
Nov 20 at 13:27




now which errors you are facing after doing above code? and if my post helps you to fix your current issue so please up vote?
– GauravRai1512
Nov 20 at 13:27












There are no error on console now but my website is not loading in browser.
– vidy
Nov 20 at 13:37




There are no error on console now but my website is not loading in browser.
– vidy
Nov 20 at 13:37












is this right way to load dispatcher servlet? @ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
– vidy
Nov 20 at 13:38




is this right way to load dispatcher servlet? @ImportResource({"classpath:spring-security.xml","classpath:dispatcher-servlet.xml"})
– vidy
Nov 20 at 13:38


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393196%2fhow-to-use-configuration-from-spring-security-xml-in-spring-boot%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'