Spring schemaLocation fails when there is no internet connection

A Spring application, built with Maven Shade plugin, was working normally, except when the internet connection was missing. . . . → Read More: Spring schemaLocation fails when there is no internet connection

Remove a dependency from pom.xml

I wrote another simple Groovy script to remove one or more dependencies from a pom.xml – Here is how to use it:

$ pomRm rdbms org.datanucleus:datanucleus-rdbms:3.0.4 $ pomRm rdbms rm org.datanucleus:datanucleus-rdbms:3.0.4 REMOVED

The first form just lists the matching artifacts, without changing the pom.xml, while adding ‘rm’ in the command line as second parameter, actually . . . → Read More: Remove a dependency from pom.xml

Check and Modify Artifacts versions in a pom.xml

Taking advantage of the easy XML processing, built in regular expressions I wrote a short script in Groovy to check and modify artifacts version in a pom.xml (Maven).

For example to show all dependencies with the word datanucleus in it, and display them in compact form (groupId:artifactId:version)

$ pomVersions datanucleus com.google.appengine.orm:datanucleus-appengine:2.0.0-RC2 org.datanucleus:datanucleus-core:3.0.4 org.datanucleus:datanucleus-api-jpa:3.0.4 org.datanucleus:datanucleus-rdbms:3.0.4

I . . . → Read More: Check and Modify Artifacts versions in a pom.xml

Mavenizing Spring Security Tutorial

I couldn’t compile Spring Security Sample Tutorial Application, so I decided to change the build system from Gradle to Maven to see it in action.

Spring Roo 1.2.0 has just been released, so I used it to create the project structure fastly. Here are the commands typed in the shell:

mkdir security-tutorial cd security-tutorial roo . . . → Read More: Mavenizing Spring Security Tutorial

Hibernate and MySQL

Since I’ve already wrote about PostgreSQL and H2 Hibernate configuration, I thought it’s a good idea to add MySQL too for my reference.

First I’ve added the dependency to Maven’s pom.xml (see the Maven repository for the latest version).

<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.18</version> </dependency>

The second step is Hibernate configuration, here is an example:

. . . → Read More: Hibernate and MySQL

Hibernate and H2

H2 is a small embeddable Java Database that supports a in memory mode (it also has a server mode). It’s a great choice for testing, since it doesn’t require any DB set up.

To try it out, the first step is adding the dependency to Maven’s pom.xml (see the Maven Repository for the latest version).

. . . → Read More: Hibernate and H2

Hibernate and PostgreSQL

I’m finally fluent in Spring and Spring-MVC and I am studying Hibernate. If I think about DBMS that I’ve been using, I can recall SQL Server, Oracle and a lot of MySQL. As for PostgreSQL, I kept on hearing good news about how robust and standard based it is, but I’ve never had a chance . . . → Read More: Hibernate and PostgreSQL

Creating a new Web Application with Eclipse and Maven

Pre-requisites: Eclipse, WTP, m2eclipse, maven

First create the new project as File > New > Maven Project > Next Uncheck “Use default Workspace location” and define a folder to host your project. Type maven-archetype-webapp and click Next. Choose Group Id, Artifact Id, Version and Package and press Finish.

At this point the project is created, . . . → Read More: Creating a new Web Application with Eclipse and Maven

Creating a WebApp project with Maven

With the archetype maven-archetype-webapp is possible to generate a simple webapps with Maven:

$ mvn archetype:generate \ -DgroupId=org.obliquid \ -DartifactId=tomcat-test \ -DarchetypeArtifactId=maven-archetype-webapp \ -Dversion=1.0-SNAPSHOT $ mvn package $ mvn tomcat:run

This starts an embedded Tomcat server and it will be browsable at http://localhost:8080/tomcat-test/

To have more detail of a Maven plugin, use the help plugin, . . . → Read More: Creating a WebApp project with Maven

External dependencies with Maven and Eclipse integration

For each external dependency, you’ll need to define at least 4 things: groupId, artifactId, version, and scope. The groupId, artifactId, and version are the same as those given in the pom.xml for the project that built that dependency. The scope element indicates how your project uses that dependency, and can be values like compile, test, . . . → Read More: External dependencies with Maven and Eclipse integration