forked from DevFW-CICD/spring-petclinic
#164 Spring Boot version of Petclinic ready to deploy to an external web container (ie Tomcat)
This commit is contained in:
parent
76a4ca330b
commit
a6e81a51a0
66 changed files with 385 additions and 1964 deletions
23
src/main/resources/application.properties
Normal file
23
src/main/resources/application.properties
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Web
|
||||
spring.mvc.view.prefix: /WEB-INF/jsp/
|
||||
spring.mvc.view.suffix: .jsp
|
||||
|
||||
|
||||
# JPA
|
||||
spring.jpa.hibernate.ddl-auto: none
|
||||
#spring.jpa.database: HSQL
|
||||
#spring.jpa.show-sql: true
|
||||
#spring.datasource.driverClassName=org.hsqldb.jdbcDriver
|
||||
spring.datasource.schema: classpath*:db/hsqldb/initDB.sql
|
||||
spring.datasource.data: classpath*:db/hsqldb/populateDB.sql
|
||||
#spring.datasource.username: sa
|
||||
#spring.datasource.password:
|
||||
|
||||
# Internationalization
|
||||
spring.messages.basename: messages/messages
|
||||
|
||||
# Actuator / Management
|
||||
management.contextPath: /manage
|
||||
|
||||
# Logging
|
||||
logging.level.org.springframework=INFO
|
||||
15
src/main/resources/banner.txt
Normal file
15
src/main/resources/banner.txt
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
|
||||
|\ _,,,--,,_
|
||||
/,`.-'`' ._ \-;;,_
|
||||
_______ __|,4- ) )_ .;.(__`'-'__ ___ __ _ ___ _______
|
||||
| | '---''(_/._)-'(_\_) | | | | | | | | |
|
||||
| _ | ___|_ _| | | | | |_| | | | __ _ _
|
||||
| |_| | |___ | | | | | | | | | | \ \ \ \
|
||||
| ___| ___| | | | _| |___| | _ | | _| \ \ \ \
|
||||
| | | |___ | | | |_| | | | | | | |_ ) ) ) )
|
||||
|___| |_______| |___| |_______|_______|___|_| |__|___|_______| / / / /
|
||||
==================================================================/_/_/_/
|
||||
|
||||
:: Built with Spring Boot :: ${spring-boot.version}
|
||||
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
|
||||
<configuration scan="true" scanPeriod="30 seconds">
|
||||
|
||||
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
|
||||
<resetJUL>true</resetJUL>
|
||||
</contextListener>
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%-5level %logger{0} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--<logger name="org.hibernate" level="debug"/> -->
|
||||
<logger name="org.springframework.samples.petclinic" level="debug"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
</configuration>
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Repository and Service layers
|
||||
-->
|
||||
<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:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
|
||||
|
||||
<!-- import the dataSource definition -->
|
||||
<import resource="datasource-config.xml"/>
|
||||
|
||||
<context:component-scan
|
||||
base-package="org.springframework.samples.petclinic.service"/>
|
||||
|
||||
<!-- 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" system-properties-mode="OVERRIDE"/>
|
||||
|
||||
<!-- enables scanning for @Transactional annotations -->
|
||||
<tx:annotation-driven/>
|
||||
|
||||
|
||||
<!-- ================== 3 Profiles to choose from ===================
|
||||
- jdbc (uses Spring" JdbcTemplate)
|
||||
- jpa
|
||||
- spring-data-jpa
|
||||
=============================================================================-->
|
||||
|
||||
<beans profile="jpa,spring-data-jpa">
|
||||
<!-- JPA EntityManagerFactory -->
|
||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
|
||||
p:dataSource-ref="dataSource">
|
||||
<property name="jpaVendorAdapter">
|
||||
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
|
||||
p:database="${jpa.database}" p:showSql="${jpa.showSql}"/>
|
||||
<!-- the 'database' parameter refers to the database dialect being used.
|
||||
By default, Hibernate will use a 'HSQL' dialect because 'jpa.database' has been set to 'HSQL'
|
||||
inside file spring/data-access.properties
|
||||
|
||||
-->
|
||||
</property>
|
||||
<!-- gDickens: BOTH Persistence Unit and Packages to Scan are NOT compatible, persistenceUnit will win -->
|
||||
<property name="persistenceUnitName" value="petclinic"/>
|
||||
<property name="packagesToScan" value="org.springframework.samples.petclinic"/>
|
||||
</bean>
|
||||
|
||||
<!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
|
||||
p:entityManagerFactory-ref="entityManagerFactory"/>
|
||||
|
||||
|
||||
<!--
|
||||
Post-processor to perform exception translation on @Repository classes (from native
|
||||
exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy).
|
||||
-->
|
||||
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
|
||||
|
||||
</beans>
|
||||
|
||||
<beans profile="jdbc">
|
||||
<!-- Transaction manager for a single JDBC DataSource (alternative to JTA) -->
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
|
||||
p:dataSource-ref="dataSource"/>
|
||||
|
||||
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<constructor-arg ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
<bean id="namedParameterJdbcTemplate"
|
||||
class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate">
|
||||
<constructor-arg ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
<context:component-scan base-package="org.springframework.samples.petclinic.repository.jdbc"/>
|
||||
</beans>
|
||||
|
||||
<beans profile="jpa">
|
||||
<!--
|
||||
Loads JPA beans
|
||||
Will automatically be transactional due to @Transactional.
|
||||
EntityManager will be auto-injected due to @PersistenceContext.
|
||||
PersistenceExceptions will be auto-translated due to @Repository.
|
||||
-->
|
||||
<context:component-scan base-package="org.springframework.samples.petclinic.repository.jpa"/>
|
||||
</beans>
|
||||
|
||||
<beans profile="spring-data-jpa">
|
||||
<jpa:repositories base-package="org.springframework.samples.petclinic.repository.springdatajpa"/>
|
||||
</beans>
|
||||
</beans>
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
# Properties file with JDBC and JPA settings.
|
||||
#
|
||||
# Applied by <context:property-placeholder location="jdbc.properties"/> from
|
||||
# various application context XML files (e.g., "applicationContext-*.xml").
|
||||
# Targeted at system administrators, to avoid touching the context XML files.
|
||||
|
||||
# Properties that control the population of schema and data for a new data source
|
||||
jdbc.initLocation=classpath:db/hsqldb/initDB.sql
|
||||
jdbc.dataLocation=classpath:db/hsqldb/populateDB.sql
|
||||
|
||||
jpa.showSql=true
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# HSQL Settings
|
||||
|
||||
jdbc.driverClassName=org.hsqldb.jdbcDriver
|
||||
jdbc.url=jdbc:hsqldb:mem:petclinic
|
||||
jdbc.username=sa
|
||||
jdbc.password=
|
||||
|
||||
# Property that determines which database to use with an AbstractJpaVendorAdapter
|
||||
jpa.database=HSQL
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# MySQL Settings
|
||||
|
||||
#jdbc.driverClassName=com.mysql.jdbc.Driver
|
||||
#jdbc.url=jdbc:mysql://localhost:3306/petclinic?useUnicode=true&characterEncoding=UTF-8
|
||||
#jdbc.username=root
|
||||
#jdbc.password=petclinic
|
||||
|
||||
# Property that determines which database to use with an AbstractJpaVendorAdapter
|
||||
#jpa.database=MYSQL
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Application context definition for PetClinic Datasource.
|
||||
-->
|
||||
<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:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
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/jdbc
|
||||
http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/jee
|
||||
http://www.springframework.org/schema/jee/spring-jee.xsd">
|
||||
|
||||
<!-- ========================= DATASOURCE DEFINITION ========================= -->
|
||||
|
||||
<!-- 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" system-properties-mode="OVERRIDE"/>
|
||||
|
||||
<!-- 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}"/>
|
||||
|
||||
<!-- 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">
|
||||
<jdbc:script location="${jdbc.initLocation}"/>
|
||||
<jdbc:script location="${jdbc.dataLocation}"/>
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<beans profile="javaee">
|
||||
<!-- JNDI DataSource for JEE environments -->
|
||||
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/petclinic"/>
|
||||
</beans>
|
||||
</beans>
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
- DispatcherServlet application context for PetClinic's web tier.
|
||||
-->
|
||||
<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:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/mvc
|
||||
http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
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">
|
||||
|
||||
<import resource="mvc-view-config.xml"/>
|
||||
|
||||
<!--
|
||||
- POJOs labeled with the @Controller and @Service annotations are auto-detected.
|
||||
-->
|
||||
<context:component-scan
|
||||
base-package="org.springframework.samples.petclinic.web"/>
|
||||
|
||||
<mvc:annotation-driven conversion-service="conversionService"/>
|
||||
|
||||
<!-- all resources inside folder src/main/webapp/resources are mapped so they can be refered to inside JSP files
|
||||
(see htmlHeader.jsp for more details) -->
|
||||
<mvc:resources mapping="/resources/**" location="/resources/"/>
|
||||
<mvc:resources mapping="/vendors/**" location="/vendors/"/>
|
||||
|
||||
<mvc:view-controller path="/" view-name="welcome"/>
|
||||
|
||||
<!-- serve static resources (*.html, ...) from src/main/webapp/
|
||||
Required when both servlet-mapping is '/' and static resources need to be served -->
|
||||
<mvc:default-servlet-handler/>
|
||||
|
||||
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
|
||||
<property name="formatters">
|
||||
<set>
|
||||
<bean class="org.springframework.samples.petclinic.web.PetTypeFormatter"/>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
- Message source for this context, loaded from localized "messages_xx" files.
|
||||
- Files are stored inside src/main/resources
|
||||
-->
|
||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
|
||||
p:basename="messages/messages"/>
|
||||
|
||||
<!--
|
||||
- This bean resolves specific types of exceptions to corresponding logical
|
||||
- view names for error views.
|
||||
-->
|
||||
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
|
||||
<!-- view name resolved using bean of type InternalResourceViewResolver (declared in mvc-view-config.xml) -->
|
||||
<property name="defaultErrorView" value="exception"/>
|
||||
<!-- results into 'WEB-INF/jsp/exception.jsp' -->
|
||||
<property name="warnLogCategory" value="warn"/>
|
||||
<!-- needed otherwise exceptions won't be logged anywhere -->
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
- DispatcherServlet application context for PetClinic's web tier.
|
||||
-->
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<!--
|
||||
- The ContentNegotiatingViewResolver delegates to the InternalResourceViewResolver and BeanNameViewResolver,
|
||||
- and uses the requested media type (determined by the path extension) to pick a matching view.
|
||||
- When the media type is 'text/html', it will delegate to the InternalResourceViewResolver's JstlView,
|
||||
- otherwise to the BeanNameViewResolver.
|
||||
-->
|
||||
<mvc:view-resolvers>
|
||||
<mvc:content-negotiation use-not-acceptable="true">
|
||||
<mvc:default-views>
|
||||
<bean class="org.springframework.web.servlet.view.JstlView">
|
||||
<property name="url" value=""/>
|
||||
</bean>
|
||||
</mvc:default-views>
|
||||
</mvc:content-negotiation>
|
||||
|
||||
<!-- Registering BeanNameViewResolver and InternalViewResolver -->
|
||||
<mvc:bean-name/>
|
||||
<mvc:jsp prefix="/WEB-INF/jsp/" suffix=".jsp"/>
|
||||
</mvc:view-resolvers>
|
||||
|
||||
<!-- Renders an XML view. Used by the BeanNameViewResolver -->
|
||||
<bean id="vets/vetList.xml" class="org.springframework.web.servlet.view.xml.MarshallingView">
|
||||
<property name="marshaller" ref="marshaller"/>
|
||||
</bean>
|
||||
|
||||
<oxm:jaxb2-marshaller id="marshaller">
|
||||
<!-- Object-XML mapping declared using annotations inside 'Vets' -->
|
||||
<oxm:class-to-be-bound name="org.springframework.samples.petclinic.model.Vets"/>
|
||||
</oxm:jaxb2-marshaller>
|
||||
|
||||
</beans>
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Application context definition for PetClinic on JPA.
|
||||
-->
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:cache="http://www.springframework.org/schema/cache"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/aop
|
||||
http://www.springframework.org/schema/aop/spring-aop.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/cache
|
||||
http://www.springframework.org/schema/cache/spring-cache.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<!--
|
||||
Simply defining this bean will cause requests to owner names to be saved.
|
||||
This aspect is defined in petclinic.jar's META-INF/aop.xml file.
|
||||
Note that we can dependency inject this bean like any other bean.
|
||||
-->
|
||||
<aop:aspectj-autoproxy>
|
||||
<aop:include name="callMonitor"/>
|
||||
</aop:aspectj-autoproxy>
|
||||
|
||||
<!-- Call monitoring aspect that monitors call count and call invocation time -->
|
||||
<bean id="callMonitor" class="org.springframework.samples.petclinic.util.CallMonitoringAspect"/>
|
||||
|
||||
<!--
|
||||
Exporter that exposes the CallMonitoringAspect via JMX,
|
||||
based on the @ManagedResource, @ManagedAttribute, and @ManagedOperation annotations.
|
||||
-->
|
||||
<context:mbean-export/>
|
||||
|
||||
<!-- enables scanning for @Cacheable annotation -->
|
||||
<cache:annotation-driven/>
|
||||
|
||||
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
|
||||
<property name="cacheManager" ref="ehcache"/>
|
||||
</bean>
|
||||
|
||||
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
|
||||
<property name="configLocation" value="classpath:cache/ehcache.xml"/>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
Loading…
Add table
Add a link
Reference in a new issue