Blog Archives

10: Spring, JavaConfig (i.e @Configuration), JPA & Hibernate by example

Example #1 Wiring JDBC Datasource



Spring loading property files & properties

conf/db.properties

# jdbc.X
jdbc.driverClassName=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:hsql://localhost/mytestdb
jdbc.user=SA
jdbc.pass=
# hibernate.X
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.show_sql=false
hibernate.hbm2ddl.auto=

#1. Register a Properties File in Application Context XML

The “<property-placeholder>” tag.



Spring, JavaConfig (@Configuration), and TransactionManager

This extedns configuring JDBC and JPA to configure the TransactionManager.

Example #1 Wiring JDBC Transaction Manager

Note: @EnableTransactionManagement annotation



Spring, JavaConfig (i.e @Configuration) & JDBC by example

Example #1 Wiring JDBC Datasource



Spring, JavaConfig (i.e @Configuration) & JMS by example

Step 1: Define the messaging system connectivity, destination (e.g. topic or queue) and message selector properties via a YAML or .properties file. Here is an example of application.yml file.



300+ Java Interview FAQs

800+ Java Interview Q&As

Top