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
Related
I am trying to understand what Spring Boot does with the "application.properties" file. I know it configures the application, but when I look inside the final JAR file gradle creates (its spring boot+gradle), I cannot find the application.properties file.
My applications works fine. But I'm curious what happens to the application.properties when the application is built and how my configurations finds its way in to the application. Can someone shed light on this?
Thanks in advance.
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
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.
Developing web application under STS 3.4.0.RELEASE (Spring). I have working JPA example under Eclipse Juno and want to port it as part of Spring application. I have to copy persistence.xml file. Where should it be located exactly?
So far I get "javax.persistence.PersistenceException: No Persistence provider for EntityManager named ..." which may be related to location or may be not.
Is there a need for "provider" element and if so what should be the value? (It worked fine under Eclipse without that element).
Please Help!!!
Your persistence.xml is not valid and the EntityManagerFactory can't get created
Refer this similar question Cause of this Exception
Hope it helps..
The persistence.xml file should be placed in META-INF/persistence.xml in your classpath.
I have checked a lot of different links for creating spring mvc with maven but I don't understand why everybody have different xml-files, someone create a webapp login/logout with only pom.xml and web.xml and someone else do the same thing but this one has an applicationservice.xml and an application-dispatcher.xml too. So I'm very confused what roles are and what is the best structure for spring mvc with maven (even JPA and JAX-RS and JAX-B included). How many xml-files I need for a project and so on.
Please
Anyone how have any idea about it?
Spring is about choice, lot of solutions are available. you can have zero spring xml files and configure it programmatically or put all spring configuration in several xml files (with <import> for instance). For persistence, you can create a simple META-INF/persistence.xml with mostly nothing and put all the JPA configuration in your xml spring files, or concentrate all JPA configurations in META-INF/persistence.xml.
For my projects my choice is:
One central XML file for main spring configuration (configuration of beans)
It contains lots of <import> to several other XML files wher I put dedicated configurations:
project-security.xml
project-persitence.xml (with a mostly empty META-INFO/persistence.xml
project-web.xml
...