The Only One Dependency You Need In Java EE 7 📎
Java EE 7 projects need only one single dependency in pom.xml:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
This javaee-api
dependency contains all Java EE 7 APIs (from EJB, JTA, JCA over CDI to JPA), is 1.8 MB big and because the server implements the APIs, it never ships with the WAR.
Mainstream Java EE projects can be easily built with the following pom.xml
:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.airhacks/groupId>
<artifactId>skinny</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>skinny</finalName>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
</project>
Gradle build script has similar length:
def WAR_NAME='skinny.war'
apply plugin: 'war'
apply plugin: 'maven'
group = 'com.airhacks'
version = '0.0.1-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
providedCompile 'javax:javaee-api:7.0'
}
compileJava {
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
}
war{
archiveName WAR_NAME
}
Project structure for skinny projects can be easily created with mvn archetype:generate -Dfilter=com.airhacks:javaee7-essentials-archetype.
See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.