mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-05-22 19:59:37 +00:00
introducing a "default" profile so default configuration is simpler
This commit is contained in:
parent
d279d45a5b
commit
c13f141251
3 changed files with 22 additions and 11 deletions
|
@ -25,8 +25,14 @@
|
||||||
<!-- enables scanning for @Transactional annotations -->
|
<!-- enables scanning for @Transactional annotations -->
|
||||||
<tx:annotation-driven />
|
<tx:annotation-driven />
|
||||||
|
|
||||||
|
|
||||||
<beans profile="jpa,spring-data-jpa">
|
<!-- ================== 3 Profiles to choose from ===================
|
||||||
|
- default (uses JPA)
|
||||||
|
- jdbc (uses Spring" JdbcTemplate)
|
||||||
|
- spring-data-jpa
|
||||||
|
=============================================================================-->
|
||||||
|
|
||||||
|
<beans profile="default,spring-data-jpa">
|
||||||
<!-- JPA EntityManagerFactory -->
|
<!-- JPA EntityManagerFactory -->
|
||||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
||||||
p:dataSource-ref="dataSource">
|
p:dataSource-ref="dataSource">
|
||||||
|
@ -69,8 +75,9 @@
|
||||||
<context:component-scan base-package="org.springframework.samples.petclinic.repository.jdbc"/>
|
<context:component-scan base-package="org.springframework.samples.petclinic.repository.jdbc"/>
|
||||||
</beans>
|
</beans>
|
||||||
|
|
||||||
<beans profile="jpa">
|
<beans profile="default">
|
||||||
<!--
|
<!--
|
||||||
|
Loads JPA beans
|
||||||
Will automatically be transactional due to @Transactional.
|
Will automatically be transactional due to @Transactional.
|
||||||
EntityManager will be auto-injected due to @PersistenceContext.
|
EntityManager will be auto-injected due to @PersistenceContext.
|
||||||
PersistenceExceptions will be auto-translated due to @Repository.
|
PersistenceExceptions will be auto-translated due to @Repository.
|
||||||
|
|
|
@ -8,15 +8,20 @@ http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||||
<display-name>Spring PetClinic</display-name>
|
<display-name>Spring PetClinic</display-name>
|
||||||
<description>Spring PetClinic sample application</description>
|
<description>Spring PetClinic sample application</description>
|
||||||
|
|
||||||
<context-param>
|
<!-- Default profile is "jpa" (see business-config.xml for more details).
|
||||||
|
When using Spring JDBC, uncomment the following: -->
|
||||||
|
<!-- <context-param>
|
||||||
<param-name>spring.profiles.active</param-name>
|
<param-name>spring.profiles.active</param-name>
|
||||||
<param-value>jdbc</param-value>
|
<param-value>jdbc</param-value>
|
||||||
<!-- Available profiles:
|
</context-param> -->
|
||||||
<param-value>jdbc</param-value>
|
|
||||||
<param-value>jpa</param-value> (in the case of plain JPA)
|
<!-- When using Spring Data JPA, uncomment the following: -->
|
||||||
<param-value>spring-data-jpa</param-value> (in the case of Spring Data JPA)
|
<!--
|
||||||
-->
|
<context-param>
|
||||||
|
<param-name>spring.profiles.active</param-name>
|
||||||
|
<param-value>spring-data-jpa</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
|
-->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
- Location of the XML file that defines the root application context.
|
- Location of the XML file that defines the root application context.
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
package org.springframework.samples.petclinic.service;
|
package org.springframework.samples.petclinic.service;
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
@ -17,7 +16,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ActiveProfiles("jpa")
|
// No active profile specificied because JPA uses the "default" profile
|
||||||
public class ClinicServiceJpaTests extends AbstractClinicServiceTests {
|
public class ClinicServiceJpaTests extends AbstractClinicServiceTests {
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue