Inscreva-se no nosso blog

by Jim Rigsbee (Red Hat)

Converting a web project generated by the JBoss Developer Studio CDI Web Project wizard to a Maven project will give you the power of the Maven build system with its dependency management, build life cycles, and automated JEE packaging abilities. To covert a JBoss Developer Studio web project, follow these steps:

1. Right click on the project name in the Project Explorer tree and select Configure → Convert to Maven Project... In the wizard steps be sure to select WAR packaging.

2. Configure the Java SE 6 compiler plugin so that we can process annotations. Add this to pom.xml file:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
            <target>1.6</target>
      </configuration>
    </plugin>
  </plugins>
</build>

3. Move the contents of the WebContent to the src/main/webapp folder. Delete the WebContent folder.

4. Create or convert source folder to src/main/java. Based on your project's needs and existing code you may also need to add or convert:

  • src/main/resources
  • src/test/java
  • src/test/resources

5. To automatically manage JEE specification library version numbers, add the JEE 6 specification dependency management BOM to the pom.xml file:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.jboss.spec</groupId>
      <artifactId>jboss-javaee-6.0</artifactId>
        <version>3.0.0.Beta1</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

6. Generate a model Maven project so that you can borrow the dependencies: Use JBoss Central and pick the Java EE Web Project:

Java EE Web Project

7. Copy the JEE 6 specification dependencies from the model project pom.xml to your project's pom.xml. Based on your project's needs consider including these artifacts:

  • cdi-api
  • jboss-annotations-api_1.1_spec
  • jboss-jaxrs-api_1.1_spec
  • hibernate-jpa-2.0-api
  • jboss-ejb-api_3.1_spec
  • jboss-transaction-api_1.1_spec
  • jboss-jsf-api_2.1_spec
  • jboss-servlet-api_3.0_spec
  • jboss-jaxb-api_2.2_spec
  • hibernate-validator

8. Right click on the project name in the Project Explorer and select Maven → Update Project Configuration...

9. Consider adding the JBoss AS plugin so that you can deploy to JBoss EAP with Maven. Add the following to the plugins section of the pom.xml file:

<plugin>
  <groupId>org.jboss.as.plugins</groupId>
  <artifactId>jboss-as-maven-plugin</artifactId>
  <version>7.1.0.Beta1b</version>
</plugin>

Now you can develop, build, and deploy inside the JBoss Developer Studio as well as build from the command line. Make sure you have the JBOSS_HOME environment variable set to the installation directory of JBoss EAP. Use the following Maven command to build and deploy your application:

        mvn package jboss-as:deploy

In the all-new JBoss Enterprise Application Development (JB225) course, students will learn more about JBoss Developer Studio tools.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.


Sobre o autor

Navegue por canal

automation icon

Automação

Saiba o que há de mais recente nas plataformas de automação incluindo tecnologia, equipes e ambientes

AI icon

Inteligência artificial

Descubra as atualizações nas plataformas que proporcionam aos clientes executar suas cargas de trabalho de IA em qualquer ambiente

cloud services icon

Serviços de nuvem

Aprenda mais sobre nosso portfólio de serviços gerenciados em nuvem

security icon

Segurança

Veja as últimas novidades sobre como reduzimos riscos em ambientes e tecnologias

edge icon

Edge computing

Saiba quais são as atualizações nas plataformas que simplificam as operações na borda

Infrastructure icon

Infraestrutura

Saiba o que há de mais recente na plataforma Linux empresarial líder mundial

application development icon

Aplicações

Conheça nossas soluções desenvolvidas para ajudar você a superar os desafios mais complexos de aplicações

Original series icon

Programas originais

Veja as histórias divertidas de criadores e líderes em tecnologia empresarial