Affichage des articles dont le libellé est maven. Afficher tous les articles
Affichage des articles dont le libellé est maven. Afficher tous les articles

jeudi 9 mai 2013

Maven et Java 7 : Fatal error compiling: invalid target release: 1.7


 Problème

Sur un projet Maven, je suis passé de java 1.6 à java 1.7 dans mon pom.xml


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project MetricViewer: Fatal error compiling: invalid target release: 1.7 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException



Solution

 Vous utilisez probablement encore Java 6.
 Pour le vérifier, faites :

mvn clean install --debug

  1 Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600)
  2 Maven home: /usr/share/maven
  3 Java version: 1.6.0_35, vendor: Apple Inc.
  4 Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home



J'ai trouvé cette solution sur http://stackoverflow.com/questions/14043042/compiling-java-7-code-via-maven

lundi 18 juillet 2011

java.lang.ClassNotFoundException: javax.faces.FacesException

Problème :

Dans JBoss 6.0.0, lorsque je déploie mon war, j'ai l'exception suivante :

java.lang.ClassNotFoundException: javax.faces.FacesException

Solution :

J'ai ajouté la dépendance Maven suivantes pour résoudre le problème :


<dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.0.0-Beta2</version> </dependency>

jeudi 7 juillet 2011

java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener

Problème :

Dans JBoss 6.0.0, lorsque je déploie mon war, j'ai l'exception suivante :

java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener 

Solution :

J'ai ajouté les dépendances Maven suivantes pour résoudre le problème :


<dependency>
 <groupId>com.sun.faces</groupId>
 <artifactId>jsf-impl</artifactId>
 <version>2.0.0-Beta2</version>
</dependency>
<dependency>
 <groupId>com.sun.faces</groupId>
 <artifactId>jsf-impl</artifactId>
 <version>2.0.0-Beta2</version>
</dependency>

dimanche 3 juillet 2011

Eclipse : Can not find the tag library descriptor for "http://java.sun.com/jsf/core"

Problème :

Dans Eclipse, j'ai l'erreur suivante : Eclipse : Can not find the tag library descriptor for "http://java.sun.com/jsf/core"

Solution :

J'ai ajouté la dépendance suivante pour qu'elle se trouve dans le classpath d'Eclipse :


<dependency>
 <groupId>com.sun.faces</groupId>
 <artifactId>jsf-api</artifactId>
 <version>2.0.0-Beta2</version>
</dependency>

samedi 2 juillet 2011

Can not find the tag library descriptor for "http://java.sun.com/jsf/html"

 Problème :

J'ai l'erreur suivante dans Eclipse : Can not find the tag library descriptor for "http://java.sun.com/jsf/html"

Solution :

Il faut ajouter les dépendances Maven suivantes pour avoir les jars dans le classpath :

<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-impl</artifactId>
  <version>2.0.0-Beta2</version>
</dependency>

mercredi 29 juin 2011

Can not find the tag library descriptor for "http://richfaces.org/a4j"

Problème :

J'ai un fichier jsp avec dedans :


<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>


Eclipse signale l'erreur suivante : Can not find the tag library descriptor for "http://richfaces.org/a4j"


Solution :

J'ai rajouté les dépendances suivantes pour avoir les jar dans le classpath :

<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-impl</artifactId>
<version>3.3.0.GA</version>
</dependency>
<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-impl-jsf2</artifactId>
<version>3.3.3.Final</version>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-ui</artifactId>
<version>3.3.3.Final</version>
</dependency>

lundi 27 juin 2011

java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable

Problème :

Lorsque je déploie mon war dans JBoss 6.0.0, j'ai l'erreur suivante :

java.lang.ClassNotFoundException: org.aspectj.util.PartialOrder$PartialComparable


Solution :

Il manque la dépendance Maven  : aspectjweaver  :

  <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.6</version>
</dependency>

vendredi 24 juin 2011

Comment ajouter log4j dabs une application Spring3 Maven avec JBoss6 ?

Pour ajouter log4j avec Maven, on a tendance à faire :

<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.15</version>
</dependency>

Or la compilation va échouer en raison de la license des artefacts utilisé pour certaines fonctionnalités dans log4j.
J'ai trouvé cet explication sur le blog suivant : http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/

If you’re using Maven to manage your project’s build and dependencies, you may have encountered some problems when trying to include the latest version of log4j as a dependency.
 Specifically, log4j 1.2.15 depends on some artifacts that are not available in the central Maven repository due to licensing issues, and thus when you try to build a project that depends on this version of log4j,
 you may not be able to download the artifacts and your build will fail.

Donc pour que cela fonctionne, il faut exclure certaines dépendances :
   <dependency>
     <groupId>log4j</groupId>
     <artifactId>log4j</artifactId>
     <version>1.2.15</version>
     <exclusions>
       <exclusion>
         <groupId>javax.mail</groupId>
         <artifactId>mail</artifactId>
       </exclusion>
       <exclusion>
         <groupId>javax.jms</groupId>
         <artifactId>jms</artifactId>
       </exclusion>
       <exclusion>
         <groupId>com.sun.jdmk</groupId>
         <artifactId>jmxtools</artifactId>
       </exclusion>
       <exclusion>
         <groupId>com.sun.jmx</groupId>
         <artifactId>jmxri</artifactId>
       </exclusion>
     </exclusions>
   </dependency>

J'ai committé l'ajout de log4j dans le trunk de mon projet tutoriel sur Spring Maven et JBoss 6 : http://code.google.com/p/lin-mon-webapp/

references :
http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/

jeudi 23 juin 2011

Maven Spring3 JBoss 6 Hibernate exemple


Je suis fier d'annoncer la première version du projet lin-mon-webapp avec Spring 3 Hibernate Maven sur JBoss 6.Le code source est disponible sur Google project :  http://code.google.com/p/lin-mon-webapp/.
Pour réussir je me suis aidé du blog suivant :http://www.nabeelalimemon.com/blog/2010/05/spring-3-integrated-with-hibernate-part-a/. (Merci ;-)))

Pour construire te déployer le war, vous aurez besoin de :

-> Maven 2
-> JBoss 6 ( In jbossweb-standalone/lib/ vous devez mettre les jars suivants :  jstl-1.1.2.jar et standard-1.1.2.jar )
-> Mysql et de créer la base intégration avec la table User :

create database integration;
GRANT ALL ON integration.* TO 'integration'@'localhost' IDENTIFIED BY 'integration';
flush privileges;
create table USER (   
user_id int(11) primary key,   
first_name varchar(30),   
last_name varchar(30),   
email varchar(30) );
insert into USER values (1, 'titi', 'toto', 'mail@gmail.com');

Puis vous pouvez consulter le nombre et la liste des utilisateurs : http://localhost:8080/monitor/users

Voici les fichiers principaux de l'application :


Maven pom.xml :

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.dr.linmon</groupId>
<artifactId>linmon</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Monitor app</name>
<repositories>
<repository>
  <id>JBoss Repo</id>
  <url>http://repository.jboss.com/maven2</url>
</repository>
</repositories>
<dependencies>
  <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>${org.springframework.version}</version>
   </dependency>
   <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${org.springframework.version}</version>
   </dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>${org.springframework.version}</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-beans</artifactId>
  <version>${org.springframework.version}</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>${org.springframework.version}</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-aop</artifactId>
  <version>${org.springframework.version}</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context-support</artifactId>
  <version>${org.springframework.version}</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-tx</artifactId>
  <version>${org.springframework.version}</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-orm</artifactId>
  <version>${org.springframework.version}</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-jdbc</artifactId>
  <version>${org.springframework.version}</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-test</artifactId>
  <version>${org.springframework.version}</version>
</dependency>    
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>  
<dependency>
    <groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.5</version>
     <scope>runtime</scope>
</dependency>



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


   <dependency>
     <groupId>log4j</groupId>
     <artifactId>log4j</artifactId>
     <version>1.2.15</version>
     <exclusions>
       <exclusion>
         <groupId>javax.mail</groupId>
         <artifactId>mail</artifactId>
       </exclusion>
       <exclusion>
         <groupId>javax.jms</groupId>
         <artifactId>jms</artifactId>
       </exclusion>
       <exclusion>
         <groupId>com.sun.jdmk</groupId>
         <artifactId>jmxtools</artifactId>
       </exclusion>
       <exclusion>
         <groupId>com.sun.jmx</groupId>
         <artifactId>jmxri</artifactId>
       </exclusion>
     </exclusions>
   </dependency>
   <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-validator</artifactId>
     <version>4.0.2.GA</version>
     <exclusions>
  <exclusion>
    <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
   </exclusion>      
     </exclusions>
   </dependency>
   <dependency>
     <groupId>org.hibernate</groupId>
     <artifactId>hibernate-annotations</artifactId>
     <version>3.4.0.GA</version>
     <exclusions>
       <!-- Exclude Commons Logging in favor of SLF4j -->
       <exclusion>
         <groupId>org.apache.commons</groupId>
         <artifactId>com.springsource.org.apache.commons.logging</artifactId>
       </exclusion>
   <exclusion>
     <groupId>xml-apis</groupId>
     <artifactId>xml-apis</artifactId>
   </exclusion>
   <exclusion>
     <groupId>org.slf4j</groupId>
     <artifactId>slf4j-api</artifactId>
   </exclusion>            
     </exclusions>
   </dependency>
   <dependency>
      <groupId>javax.persistence</groupId>
      <artifactId>persistence-api</artifactId>
      <version>1.0</version>
    </dependency>
   <dependency>
     <groupId>commons-dbcp</groupId>
     <artifactId>commons-dbcp</artifactId>
     <version>1.2.2</version>
   </dependency>
   <dependency>
     <groupId>org.aspectj</groupId>
     <artifactId>aspectjrt</artifactId>
     <version>${aspectj.version}</version>
   </dependency>
  <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>


<build>
<finalName>monitor</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<verbose>true</verbose>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.4</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
</build>
  
<properties>
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
    <aspectj.version>1.6.6</aspectj.version>    
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
</project>


First the web.xml in whicn we create the servlet monitor :

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
  <display-name>Maven Spring MVC 3 with JBOSS 6 </display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/spring.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>     
  
  <!-- Front servlet.  -->
  <servlet>
<servlet-name>monitor</servlet-name>
<display-name>monitor</display-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/monitor-servlet.xml</param-value>
    </init-param>
<load-on-startup>1</load-on-startup>
  </servlet>
 
<!-- Every request on / will be treat by monitor servlet. -->
  <servlet-mapping>
<servlet-name>monitor</servlet-name>
<url-pattern>/</url-pattern>
  </servlet-mapping>

</web-app>

Then there is the monitor servlet which define the controller, view relover ... and also where to search controller methos:

monitor-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byName">
<!-- Every contoller is automaticaly detect due to annotation @Controller.
    We define here in wich package the post processor have to search controller annotation -->
  <context:component-scan base-package="fr.dr.monitor.controller"/>  

<context:annotation-config/>

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<bean 
class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/>
</beans>



The controller class contains this method :

@RequestMapping(value = "users", method = RequestMethod.GET)
public ModelAndView getUsers() {
  List<User> users = userDAO.getUsers();
  ModelAndView modelAndView = new ModelAndView("users");
  modelAndView.addObject("users", users);
  return modelAndView;
}  

To do that the controller call UserDAO methods and Hibernate will retreive data in User table.
Here is the spring beans file that create Hibernate Session and datasource :

spring.xml


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">


 <!--  <context:component-scan base-package="com.springhibernate.integration.aspects" />-->

 <!--Enables the use of @AspectJ style of aspects' declarations. AspectJ run-time isn't necessarily involved-->
 <aop:aspectj-autoproxy/>

 <!--Platform Transaction Manager declared as "transactionManager" will be used.-->
 <!--"aspectj" mode enables load-time/compile-time weaving of transactional methods, which enables
  those methods to be intercepted even when called internally.
  (Unlike Spring generated proxies which will only be intercepted when called from outside)--> 
 <tx:annotation-driven transaction-manager="transactionManager"/>

<!--
Activates various annotations to be detected in bean classes: Spring's
@Required and @Autowired, as well as JSR 250's @PostConstruct,
@PreDestroy and @Resource (if available) and JPA's @PersistenceContext
and @PersistenceUnit (if available).
-->
<context:annotation-config/>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
 <property name="dataSource" ref="dataSource"/>
 <property name="hibernateProperties">
   <props>
     <prop key="dialect">org.hibernate.dialect.MySQL5Dialect</prop>
     <prop key="show_sql">true</prop>
   </props>
 </property>
 <property name="mappingResources">
   <list>
     <value>mappings/user.hbm.xml</value>
   </list>
 </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
 <property name="sessionFactory" ref="sessionFactory"/>
</bean>

<context:property-placeholder location="classpath*:/META-INF/properties/*.properties"/>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
 <property name="driverClassName" value="${database.driverClassName}"/>
 <property name="url" value="${database.url}"/>
 <property name="username" value="${database.username}"/>
 <property name="password" value="${database.password}"/>
</bean>



  <!--repository init area-->
  <bean id="repository.users" class="fr.dr.monitor.repository.UserDAO"
        autowire="constructor"/>
</beans>

The session factory will be inject to UserDAO to query on USER table :

UserDAO.java

@Repository
@Transactional
public class UserDAO implements IUser {

private SessionFactory sessionFactory;

@Autowired
public UserDAO(SessionFactory sessionFact) {
this.sessionFactory = sessionFact;
}

@Transactional
public User getUser(Long id) {
return (User) sessionFactory.getCurrentSession().get(User.class, id);
}

@SuppressWarnings("unchecked")
@Transactional
public List<User> getUsers() {
return sessionFactory.getCurrentSession().createQuery("from User user").list();
}

@Transactional
public void addUser(User user) {
sessionFactory.getCurrentSession().save(user);
}
}

All the code is available on google project with Apache License V2 : http://code.google.com/p/lin-mon-webapp/ 

mercredi 22 juin 2011

org.apache.jasper.JasperException: L'uri absolue: http://java.sun.com/jsp/jstl/core ne peut être résolu

Problème :


Lors de l'affichage d'une page JSP (avec JBoss 6.0.0), j'ai l'erreur suivante :
org.apache.jasper.JasperException: L'uri absolue: http://java.sun.com/jsp/jstl/core ne peut être résolu dans le fichier web.xml ou dans les fichiers jar déployés avec cette application.

Solution :


J'ai résolu ce problème en enlevant le scope provided dans le pom.xml de mon application pour la dépendance jstl.jar :


    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.1.2</version>
    </dependency>
    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <scope>provided</scope>
      <version>1.1.2</version>
    </dependency>

vendredi 3 juin 2011

Maven Spring MVC 3 with JBOSS 6 example

Objectifs :

Le principal objectifs de cet exemple est de montrer une configuration Maven qui fonctionne pour Spring MVC 3 et JBoss6.
Le code source est disponible sur Google code : http://code.google.com/p/lin-mon-webapp/ (cf wiki tutorial1)

Arborescence du projet :



Maven :

Il faut noter que la version de Spring qui est utilisée est la version 3.0.5.Les versions antérieurs ne fonctionne pas avec JBOSS 6 du fait d'un bug sur le VFS de JBOSS. Dans ce projet exemple, je n'ai mis que les dépendances utiles (à vous de me dire si je ne dit pas de bétises ...)


Voici le pom.xml du projet :

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>fr.dr.monitor</groupId>
    <artifactId>monitor</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Monitor app</name>
    
    <dependencies>
      <dependency>
            <groupId>org.springframework</groupId>
     <artifactId>spring-beans</artifactId>
     <version>${org.springframework.version}</version>
      </dependency>


      <dependency>
    <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
    <version>${org.springframework.version}</version>
      </dependency>
      <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
     <version>${org.springframework.version}</version>
      </dependency>


      <dependency>
     <groupId>javax.servlet</groupId>
     <artifactId>servlet-api</artifactId>
     <version>2.5</version>
      </dependency>  


      <dependency>
     <groupId>taglibs</groupId>
     <artifactId>standard</artifactId>
     <version>1.1.2</version>
      </dependency>
      <dependency>
     <groupId>javax.servlet</groupId>
     <artifactId>jstl</artifactId>
     <version>1.1.2</version>
      </dependency>


      <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.5</version>
     <scope>runtime</scope>
      </dependency>
      <dependency>
     <groupId>log4j</groupId>
     <artifactId>log4j</artifactId>
     <version>1.2.14</version>
      </dependency>
</dependencies>


<build>
<finalName>monitor</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<verbose>true</verbose>
</configuration>
</plugin>

<!-- Permet de créer un projet eclipse avec Maven -->
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.4</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
</build>
  
<properties>
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
</project>


src/main/resources/spring.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/tx/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byName">
<!--
Activates various annotations to be detected in bean classes: Spring's
@Required and @Autowired, as well as JSR 250's @PostConstruct,
@PreDestroy and @Resource (if available) and JPA's @PersistenceContext
and @PersistenceUnit (if available).
-->
<context:annotation-config/>
</beans>



/WEB-INF/web.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
  <display-name>Maven Spring MVC 3 with JBOSS 6 </display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/spring.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>     
  
  <!-- declare la servlet frontale centrale  -->
  <servlet>
<servlet-name>monitor</servlet-name>
<display-name>monitor</display-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/monitor-servlet.xml</param-value>
    </init-param>
<load-on-startup>1</load-on-startup>
  </servlet>
 
  <servlet-mapping>
<servlet-name>monitor</servlet-name>
<url-pattern>/</url-pattern>
  </servlet-mapping>

</web-app>


/WEB-INF/monitor-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Fichier de conf du contexte d'application pour spring (fichier nommé spring-mvc-webapp-servlet.xml selon la convention. -->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byName">
<!-- - Tous les controlleurs sont automatiquement détectés grâce à l'annotation @Controller.
- On définit ici dans quel package le post processor doit chercher ces beans annotés. -->
  <context:component-scan base-package="fr.dr.monitor.controller"/>  
<!-- Activates various annotations to be detected in bean classes: Spring's
@Required and @Autowired, as well as JSR 250's @PostConstruct,@PreDestroy and 
@Resource (if available) and JPA's @PersistenceContext & @PersistenceUnit.
-->
<context:annotation-config/>
<!--
- Les controlleurs de cette application fournissent une annotation @RequestMapping 
- Qui peuvent être déclaré de deux manière différentes:
-  Au niveau de la classe : 
-      par exemple @RequestMapping("/addVisit.html")
-      Pour ce type de controlleurs on peut annoter les méthodes pour une requete Post ou Get,
- Au niveau de chaque méthodes, différents exemples  seront fournis.  
-->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<!--
Ceci est le view resolver, il permet de définir la technologie de vue utilisée et comment
sélectionner une vue. Ici on prendra la solution la plus simple elle permet de mapper 
le nom de la vue retournée avec la sélection d'une jsp. Ex. si le nom de la vue retournée est "hello" alors on utilisera le fichier
WEB-INF/jsp/hello.jsp pour constuire la vue. 
-->
<bean 
class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/>
</beans>


/WEB-INF/jsp/index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page isELIgnored ="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Home</title>
</head>
<body>

Bonjour ${name},

</body>
</html>


fr.dr.monitor.controller.MainController

package fr.dr.monitor.controller;


import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;




@Controller
public class MainController  {


final Logger logger=Logger.getLogger(getClass().getName());


/**
   * Handler de la méthode Get pour l'URL /helloSpringMVC.html. 
   * 
   * @param name le nom que l'on doit afficher dans la vue.
   * @param model une map de toutes les données qui seront utilisables dans la vue 
   * @return le nom de la vue qu'il faudra utiliser.
   */
 @RequestMapping(value="/")
 public  String toIndex(
   @RequestParam(value="name",required=false) String name, 
   ModelMap model) 
 {
logger.info(">toIndex");
   model.addAttribute("name",name);
   logger.info(">add attribute name " + name);
   
   // on utilisera donc le fichier /WEB-INF/jsp/index.jsp
   //au regard de la stratégie de résolution des vues 
   //utilisée dans cette application.
   return "index";
 }


}

Réferences :
http://blog.springsource.com/2011/01/04/green-beans-getting-started-with-spring-mvc
http://www.jairrillo.com/blog/2009/04/22/creating-a-project-using-maven-jsf-richfaces-facelets-tomahawk-hibernate-in-5-minutes/