I am new to Spring Security and I was trying to add spring security namespace. Do I need to add this to serverlet-context.xml. In my Eclipse>Spring MVC project it looks like that is the only file that has namespace information. The other two xml files are web.xml & root-context.xml.
Where do I put the namespace information?
It will depend on how your app is split up and what you want to secure. The web.xml file is not a spring configuration file so you can't put Spring Security configuration in there. Putting it in the servlet-context.xml should be OK.
However, if you are at this stage, you should probably start with one of the sample applications. Also take a look at this getting started guide on spring.io which uses Java configuration with Spring Boot which is a much nicer combination.
Related
I am using Spring MVC to create my WebSite.
But I dont understand how/where put my resources if I want to used application.properties instead of xml configuration.
I have enable #EnableAutoConfiguration tag in my project.
I have this project structure.
I'm using JSP like this:
<img src="/images/logo-ack.png" style="width: 60%;">
How I can access to this resources setting the path on application.properties?
You can use Spring initializr for this, because it will starts a project with structure offered by Spring. The website is https://start.spring.io/
tl/dr (How) Is it possible to use a jar library, that uses Spring Boot for configuration in a non Spring Boot (regular old-school Spring) server.
We have the problem, that we have a Spring server, that is from the pre-Boot times and we want to create a new library for it. We would like to use Spring Boot in the library (i.e. #EnableAutoConfiguration for configuration). To include the library we have put an spring.xml into the library that enables component-scan inside the library. The classes inside the library use #EnableAutoConfiguration and #EnableWebSecurity to enable configuration and security.
If we include now the library into our server and import the XML file from the library into the server's XML file, only parts of the configuration are working. The #RequestMappings in the library are working and the interfaces are available. However Spring security fails to register it's default filter chain, leading to ugly errors, where the regular Spring Boot config should already work with AnonymousAuthorizationFilter, etc.
We debugged, that the FilterRegistrationBean in spring security is never configured when running that way (and is, if we are running as a Spring Boot application).
So is there a common way how to deal with Spring Boot enabled libraries inside old-school Spring servers?
Is placing a single XML to enable component-scan in the library and importing this XML inside the main server's XML the correct way to include Spring Boot libraries (and how would be the best way, if the server would use Spring Boot itself)?
Does anyone know of the issue with a missing Spring Security filter chain?
PS: I know that we can add the required filters manually. However if we would do that, we would anyway get rid of Spring Boot completely in the library, so this question mainly aims for how to do it with Spring Boot. Of course if it is the wrong way to enable Spring Boot inside a library, please also mention that :-)
I am using Spring Security in my project. I have a situation where I need to change the pattern attribute in itercept-url tag on runtime. For this I have to again restart the tomcat server and in turn takes a lot of time for me to test my changes.
Does Spring have a solution where the security.xml file is reloaded when I edit it in my web application, without restarting my server. Please provide some pointers for the same as I am new to Spring Framework.
Any link to a step by step tutorial will certainly help a lot.
Thanks in advance.
Divyang Agrawal
Use spring annotation rather than using xml configuration. so by using annotation you do not required tomcat restart after changing the source code.
you can find simple tutorial for how to use annotation based spring security here Link
The answer of this question will be very helpful for me to resolve my previous question.
here.
I am trying simple Spring-MVC (with JPA) application. I want to include every necessary connection values in persistence.xml file only. In my application there are only 2 XMl files.
1) web.xml and 2) persistence.xml
Please check my previous question ( here.) for errors and persistence.xml file.
I am searching on net but not getting proper answer.
Please help me. Thank you very much in advance.
If you are using Spring / springMVC then you need to configure the datasource in the spring application context xml file only. All your contents from persistence.xml should be placed in the spring application context xml. Because spring is the core base framework which manages hibernate.
Check this http://viralpatel.net/blogs/spring3-mvc-hibernate-maven-tutorial-eclipse-example/
In this example its configured in spring-servlet.xml
I started a new Spring project without any XML configuration file. I become a big fan of annotation config. So I tried to include DWR library, which I used in my last projects. But I cannot find any tutorial, how to integrate DWR 3 in an java config spring environment.
Is this already possible, or can somebody recommend another solution where I dont have to use XML configuration files?
You can follow below two links.
Sample codes are also in the link
http://krams915.blogspot.com/2011/01/spring-mvc-3-and-dwr-3-integration.html
Spring 3 MVC integration with DWR with Annotation