mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:35:50 +00:00
Merge 880c619ef4
into d279d45a5b
This commit is contained in:
commit
070778aa16
3 changed files with 25 additions and 16 deletions
|
@ -20,7 +20,7 @@
|
|||
|
||||
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
|
||||
<!-- (in this case, JDBC-related settings for the JPA EntityManager definition below) -->
|
||||
<context:property-placeholder location="classpath:spring/data-access.properties"/>
|
||||
<context:property-placeholder location="classpath:spring/data-access.properties" system-properties-mode="OVERRIDE"/>
|
||||
|
||||
<!-- enables scanning for @Transactional annotations -->
|
||||
<tx:annotation-driven />
|
||||
|
@ -52,7 +52,7 @@
|
|||
|
||||
</beans>
|
||||
|
||||
<beans profile="jdbc">
|
||||
<beans profile="default,jdbc">
|
||||
<!-- Transaction manager for a single JDBC DataSource (alternative to JTA) -->
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
|
||||
p:dataSource-ref="dataSource"/>
|
||||
|
|
|
@ -5,11 +5,14 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
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/jee
|
||||
http://www.springframework.org/schema/jee/spring-jee.xsd
|
||||
http://www.springframework.org/schema/jdbc
|
||||
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
|
||||
|
||||
|
@ -17,20 +20,16 @@
|
|||
|
||||
<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
|
||||
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
|
||||
<context:property-placeholder location="classpath:spring/data-access.properties"/>
|
||||
<context:property-placeholder location="classpath:spring/data-access.properties" system-properties-mode="OVERRIDE"/>
|
||||
|
||||
<!-- DataSource configuration for the tomcat jdbc connection pool
|
||||
See here for more details on commons-dbcp versus tomcat-jdbc:
|
||||
|
||||
<!-- DataSource configuration for the tomcat jdbc connection pool
|
||||
See here for more details on commons-dbcp versus tomcat-jdbc:
|
||||
http://blog.ippon.fr/2013/03/13/improving-the-performance-of-the-spring-petclinic-sample-application-part-3-of-5/-->
|
||||
<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
|
||||
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
|
||||
p:username="${jdbc.username}" p:password="${jdbc.password}"/>
|
||||
|
||||
<!-- JNDI DataSource for JEE environments -->
|
||||
<!--
|
||||
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
|
||||
-->
|
||||
|
||||
<!-- Database initializer. If any of the script fails, the initialization stops. -->
|
||||
<!-- As an alternative, for embedded databases see <jdbc:embedded-database/>. -->
|
||||
<jdbc:initialize-database data-source="dataSource">
|
||||
|
@ -38,4 +37,8 @@
|
|||
<jdbc:script location="${jdbc.dataLocation}"/>
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<beans profile="production" >
|
||||
<!-- JNDI DataSource for JEE environments -->
|
||||
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
|
||||
</beans>
|
||||
</beans>
|
|
@ -8,15 +8,21 @@ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
|||
<display-name>Spring PetClinic</display-name>
|
||||
<description>Spring PetClinic sample application</description>
|
||||
|
||||
<!--
|
||||
You can override the default profile ('jdbc') with
|
||||
- jpa: in the case of plain JPA
|
||||
- spring-data-jpa: in the case of Spring Data JPA
|
||||
|
||||
You can also combine the repositories implementation profile ('jdbc', 'jpa' or 'spring-data-jpa')
|
||||
with the 'production' profile to us a JNDI datasource that would be provided by the container.
|
||||
Sample to combine JPA repository and jndi datasource: 'jpa,production'
|
||||
|
||||
Sample:
|
||||
<context-param>
|
||||
<param-name>spring.profiles.active</param-name>
|
||||
<param-value>jdbc</param-value>
|
||||
<!-- Available profiles:
|
||||
<param-value>jdbc</param-value>
|
||||
<param-value>jpa</param-value> (in the case of plain JPA)
|
||||
<param-value>spring-data-jpa</param-value> (in the case of Spring Data JPA)
|
||||
-->
|
||||
<param-value>jpa</param-value>
|
||||
</context-param>
|
||||
-->
|
||||
|
||||
<!--
|
||||
- Location of the XML file that defines the root application context.
|
||||
|
|
Loading…
Reference in a new issue