# ejb-3
mkdir -p jee-project/ejb/src/main/java
mkdir -p jee-project/ejb/src/main/resources
mkdir -p jee-project/ejb/src/test/java
#web
mkdir -p jee-project/web/src/main/java
mkdir -p jee-project/web/src/main/resources
mkdir -p jee-project/web/src/main/webapp
mkdir -p jee-project/web/src/test/java
#ear
mkdir -p jee-project/ear
<? xml version = "1.0" encoding = "UTF-8"?> <project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion> 4.0.0 </ modelVersion> <! - Group identifier. Just a way to group projects. -> <groupId> my.labs </ groupId> <! - ID of the project itself. -> <artifactId> jee-project </ artifactId> <! - An important point. Indicates the "type" of the project. If the project contains subprojects (modules) - "pom" must be specified -> <packaging> pom </ packaging> <! - Version. SNAPSHOT indicates that work is underway. Ideology maven suggests that development is on SHAPSHOT-versions. By readiness with the help of special release procedures. It is better to follow the generally accepted pattern, less surprises will be -> <version> 1.0-SNAPSHOT </ version> <! - We list the modules included in the current project, in fact - this is the name of the directories, in which maven will look for child modules. -> <modules> <module> ejb </ module> <module> web </ module> <module> ear </ module> </ modules> <! - In the dependencyManagement block, the dependencies are specified, which are found throughout the project, including in modules. In the subprojects themselves, it suffices to refer to the dependencies already mentioned. -> <dependencyManagement> <dependencies> <! - junit will be used for testing, as discussed by <scope> test </ scope> -> <dependency> <groupId> junit </ groupId> <artifactId> junit </ artifactId> <version> 4.4 </ version> <scope> test </ scope> </ dependency> <! - dependency set for JavaEE -> <dependency> <groupId> javax.annotation </ groupId> <artifactId> jsr250-api </ artifactId> <version> 1.0 </ version> <scope> provided </ scope> </ dependency> <dependency> <groupId> javax.ejb </ groupId> <artifactId> ejb-api </ artifactId> <version> 3.0 </ version> <scope> provided </ scope> </ dependency> <dependency> <groupId> javax.jms </ groupId> <artifactId> jms </ artifactId> <version> 1.1 </ version> <scope> provided </ scope> </ dependency> <dependency> <groupId> javax.persistence </ groupId> <artifactId> persistence-api </ artifactId> <version> 1.0 </ version> <scope> provided </ scope> </ dependency> <dependency> <groupId> javax.servlet </ groupId> <artifactId> servlet-api </ artifactId> <version> 2.5 </ version> <scope> provided </ scope> </ dependency> </ dependencies> </ dependencyManagement> <! - we specify the source code encoding and java version -> <build> <plugins> <plugin> <groupId> org.apache.maven.plugins </ groupId> <artifactId> maven-compiler-plugin </ artifactId> <configuration> <source> 1.6 </ source> <target> 1.6 </ target> <encoding> UTF-8 </ encoding> </ configuration> </ plugin> </ plugins> </ build> </ project>
<packaging> ejb </ packaging>and describe the ejb3 build settings
<build> <plugins> <plugin> <groupId> org.apache.maven.plugins </ groupId> <artifactId> maven-ejb-plugin </ artifactId> <version> 2.1 </ version> <configuration> <ejbVersion> 3.0 </ ejbVersion> </ configuration> </ plugin> </ plugins> </ build>
<build> <plugins> <plugin> <groupId> org.apache.maven.plugins </ groupId> <artifactId> maven-ear-plugin </ artifactId> <version> 2.3.2 </ version> <configuration> <version> 5 </ version> <! - we list modules -> <modules> <ejbModule> <groupId> $ {project.groupId} </ groupId> <artifactId> ejb </ artifactId> </ ejbModule> <webModule> <groupId> $ {project.groupId} </ groupId> <artifactId> web </ artifactId> </ webModule> </ modules> <! - the same element that specifies the need to specify all libraries in application.xml -> <includeLibInApplicationXml> true </ includeLibInApplicationXml> </ configuration> </ plugin> </ plugins> <finalName> $ {project.parent.artifactId} </ finalName> </ build>
mvn package
Source: https://habr.com/ru/post/95749/
All Articles