background preloader

Maven

Facebook Twitter

Maven - Welcome to Apache Maven. Adding and Filtering External Web Resources. The default resource directory for all Maven projects is src/main/resources which will end up in target/classes and in WEB-INF/classes in the WAR.

Adding and Filtering External Web Resources

The directory structure will be preserved in the process. The WAR Plugin is also capable of including resources not found in the default resource directory through the webResources parameter. Adding web resources <project> ... <build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>2.4</version><configuration><webResources><resource><! Using our sample project in the usage section with an added external resource, like this: . |-- pom.xml |-- resource2 | |-- external-resource.jpg | `-- image2 | `-- external-resource2.jpg `-- src `-- main |-- java | `-- com | `-- example | `-- projects | `-- SampleAction.java |-- resources | `-- images | `-- sampleimage.jpg `-- webapp |-- WEB-INF | `-- web.xml |-- index.jsp `-- jsp `-- websource.jsp would end up in the WAR as: Configuring web Resources ...

Creating Skinny WARs. In a typical J2EE environment, a WAR is packaged within an EAR for deployment.

Creating Skinny WARs

The WAR can contain all its dependent JARs in WEB-INF/lib but then the EAR can quickly grow very large if there are multiple WARs, due to the presence of duplicate JARs. Instead the J2EE specification allows WARs to reference external JARs packaged within the EAR via the Class-Path setting in their MANIFEST.MF . The Maven WAR and EAR Plugins do not directly support this mode of operation but we can fake it through some POM and configuration magic.

First you need to tell Maven to exclude the dependent JARs and add references to them in the MANIFEST.MF instead. This goes into your WAR project's pom.xml : <project> ... Here's another variant of the above example, but this time we use <packagingIncludes> to select a few JARs to be included in the WAR. <project> ... Next we need to change the EAR project's pom.xml to package those dependent JARs in the EAR. ... Now the painful part. .... Building For Different Environments with Maven 2. Stack Overflow. Java - How do I get Maven 2 to build 2 separate WAR files. Maven 3 + Hibernate 3.6 + Oracle 11g Example (XML Mapping) In this article, we show you how to integrate Maven3, Hibernate3.6 and Oracle11g together.

Maven 3 + Hibernate 3.6 + Oracle 11g Example (XML Mapping)

In the end of this article, you will create a Java project with Maven, and insert a record into Oracle database via Hibernate framework. Tools & technologies used in this article : Maven 3.0.3JDK 1.6.0_13Hibernate 3.6.3.finalOracle 11g 1. Table Creation Oracle SQL script to create a “DBUSER” table in database. 2. Use Maven to create a standard project structure. mvn archetype:generate -DgroupId=com.mkyong -DartifactId=HibernateExample -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false 3. Convert the generated Maven based project to Eclipse project, and import it into your Eclipse IDE. 4.

Update your pom.xml file, and add all related dependencies. You need declared “JBoss repository” for the latest Hibernate jar and its dependency.For Oracle JDBC driver, you need to install it into your local maven repository manually. Maven em 5 Minutos. Veja como em pouco tempo já conseguimos criar um projeto no Maven!

Maven em 5 Minutos

Instalação Maven é uma ferramenta Java, portanto, é necessário ter o Java instalado para prosseguir. Para início de conversa, faça o download do Maven e siga as instruções de instalação. Após este passo digite o seguinte comando no terminal ou no prompt de linha de comando: mvn –version ou também mvn –v. Atenção amantes do Linux, sim eu uso Windows! Atenção, segundo o próprio site do Maven, dependendo da sua configuração de rede, você pode precisar de mais configurações extras.

Criando um projeto Abra uma nova linha de comando e execute o seguinte comando: