I'm developing a new Spring+JPA2/Hibernate+Wicket project and am wondering where some of the configuration files should go?
applicationContext.xml I've seen this both in src/main/resources/META-INF and just src/main/resources/
persistence.xml Most of the time, I've seen it in src/main/resources/META-INF. In my c开发者_JAVA百科ase, it contains the following:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
version="1.0">
<persistence-unit name="ApplicationEntityManager" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
</persistence-unit>
</persistence>
web.xml I guess src/main/webapp/WEB-INF is the correct place.
persistence.xml
must be insrc/main/resources/META-INF
applicationContext.xml
can be anywhere, as long as you configure it withcontextConfigLocation
. By default spring looks for it inWEB-INF
, so it has to be insrc/main/webapp/WEB-INF
. But I think it better be insrc/main/resources
.<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param>
Note that for unit tests you can override these files by placing the test-alternatives in src/test/**
Generally speaking, all resources should be in src/main/resources
. (reraly in META-INF
)
精彩评论