Spring Roo, Maven and Oracle JDBC drivers

Oracle JDBC drivers are not freely available in any public Maven repos. Per the Spring Roo docs, if you have an Oracle product installed (presumably you do if you’re trying to connect to it), you can install the provided JDBC driver into your local Maven repo for your code to build successfully.

Using Roo 1.1.5, setting up my persistence with:

persistence setup --provider HIBERNATE --database ORACLE --databaseName XE

Resulted in this dependency added to my pom.xml:

	<dependency>
		<groupId>com.oracle</groupId>
		<artifactId>ojdbc14</artifactId>
		<version>10.2.0.2</version>
		<classifier />
	</dependency>

I’m using Oracle Express 11.2.2.0 on my machine, and my JDBC driver installed with the product is here:

C:oraclexeapporacleproduct11.2.0serverjdbclibojdbc6.jar

So using the Maven install command, I can copy this file into my local repo like this:

mvn install:install-file 
    -Dfile=ojdbc6.jar 
    -DgroupId=com.oracle 
    -DartifactId=ojdbc6 
    -Dversion=11.2.0.2.0 
    -Dpackaging=jar 
    -DgeneratePom=true

And then update my jar dependency in my pom.xml to match the version of the jar that I have:

	<dependency>
		<groupId>com.oracle</groupId>
		<artifactId>ojdbc14</artifactId>
		<version>11.2.0.2.0</version>
		<classifier />
	</dependency>

Maven and JAXB

Add this dependency to your pom.xml:

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.5-b10</version>
</dependency>

If you have your jaxb.index file in your src/main/java source tree (probably should be in src/main/resources instead, unless you’d rather see it alongside your source), then you’ll also need a file pattern include in your build section:

<resources>
<!-- include jaxb index files -->
    <resource>
        <directory>src/main/java</directory>
        <includes>
            <include>**/*.index</include>
        </includes>
    </resource>
</resources>

Maven: Changing the Java target version

Maven defaults to Java 1.5 by default. You can change this via settings on the maven compiler plugin:

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

Alternatively, you can specify the source and target Java verison using these properties:

    <properties>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>