On 2/9/07, viggo <[EMAIL PROTECTED]> wrote:
I created in m2 a modular spring project, which I have tried to update on every new milestone. Today (running m4) I have two applicationContext-resources.xml, one in core/src/test/resources and one in web/src/main/resources. Do I need both? If yes, what should the content be?
Yes, you need both since a "dataSource" bean is needed by your application. You'll notice that for testing, the one in core uses a standard datasource whereas the one in web uses a connection pool. This is for faster testing. It also allows you to switch your webapp to using JNDI if you like. Of course, you can move the applicationContext-resources.xml from web to core/src/main/resources and it will be packaged in the JAR - but that somewhat limits your flexibility. core/src/test/resources/applicationContext-resources.xml:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" 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-2.0.xsd"> <bean id="propertyConfigurer" class=" org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> </list> </property> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> </beans> web/src/main/resources/applicationContext-resources.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd"> <!-- For mail settings and future properties files --> <bean id="propertyConfigurer" class=" org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> <value>classpath:mail.properties</value> </list> </property> </bean> <!-- JNDI DataSource for J2EE environments --> <!--<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/appfuse"/>--> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> <property name="maxActive" value="100"/> <property name="maxIdle" value="30"/> <property name="maxWait" value="1000"/> <property name="defaultAutoCommit" value="true"/> <property name="removeAbandoned" value="true"/> <property name="removeAbandonedTimeout" value="60"/> </bean> </beans> Do I really need a datasource in the web module? I thought all database access was going through a manager at the service layer. I also go two hibernate.cfg.xml files, one in core and one in web. I've seen issues about this, but what is the current status?
If you move the one from web to src/main/resources in core, you can delete the one in web. The reason things are setup this way is because we use svn:externals to pull the source of the basic archetypes into the web module of the modular archetypes. Matt --
View this message in context: http://www.nabble.com/applicationContext-resources.xml-and-hibernate.cfg.xml-tf3200076s2369.html#a8884758 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- http://raibledesigns.com
