Création d’un archetype maven

1.Introduction

Création d’un archetype maven à partir d’un projet existant

2.Mise en oeuvre

2.1 Génération

Lancer la commande suivante afin de créer un projet de base

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp

Un fois le projet crée placez vous à la racine de celui-ci et lancer la commande ci-dessous afin de générer l’archetype

mvn archetype:create-from-project

La structure de l’archetype et stocké dans « target\generated-sources\archetype ». Je vous conseille de déplacer et renommer le dossier archetype, c’est dans ce dossier que nous allons dorénavant travailler afin de modifier notre archetype

2.1 Personalisation

Tout ce qui nous concerne se trouve dans src/main/resources/META-INF/maven et src/main/resources/archetype-resources n’hésitez pas lire cette doc

2.2 Installation dans votre repository local

mvn install

Setup Liferay Mysql Glassfish

1.Introduction

Migration du portal vers MySQL

Créer dans le répertoire /domain/domain1/applications/j2ee-module/liferay-portal/WEB-INF/classes/ le fichier portal-ext.properties

jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=lportal
jdbc.default.password=lportalpassword

Un environnement de développement Java proche de la perfection…

1.Introudction

Combien de fois ai-je entendu que le fait de compiler, déployer des applications Java était bien plus compliqué que des langages scriptés comme PHP. C’est vrai, cependant rien n’empêche le développeur JAVA web d’utiliser de nouveaux programmes lui facilitant la vie…Dans cette article, j’aimerais vous présenter quelques « nouveaux » plugins

Lire la suite

Accès MySql via Spring et jndi, tomcat

1.Configuration

Placer le jar de mysql dans le répertoire lib de tomcat

2.Dossier META-INF, context.xml de l’application

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/myApp">
    <!-- Specify a JDBC datasource -->
    <Resource name="jdbc/dbmyapp" auth="Container" type="javax.sql.DataSource"
        username="user" password="password" driverClassName="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost:3306/database?autoReconnect=true"
        validationQuery="select 1" maxActive="10" maxIdle="4" />
     
   <!-- To work with the authentification -->
   <Realm className="org.apache.catalina.realm.DataSourceRealm"
    dataSourceName="jdbc/database"
    localDataSource="true"
    roleNameCol="LB_ROLENAME"
    userCredCol="LB_PASSWORD"
    userNameCol="LB_USERNAME"
    userRoleTable="T_ROLE"
    userTable="T_USER"/>
</Context>

3. applicationContext.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:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:flow="http://www.springframework.org/schema/webflow-config"
       xmlns:jms="http://www.springframework.org/schema/jms"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:lang="http://www.springframework.org/schema/lang"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:p="http://www.springframework.org/schema/p"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.0.xsd
       http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-2.5.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
       http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
       http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
    <!--bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
          p:location="/WEB-INF/jdbc.properties" />
 
    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.url}"
          p:username="${jdbc.username}"
          p:password="${jdbc.password}" /-->
 
 
    <!-- JPA -->
 
    <tx:annotation-driven />
     
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql" value="true" /> <!-- Prints used SQL to stdout -->
                <property name="generateDdl" value="true" /> <!-- Generates tables. -->            
               <!-- <property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect" />-->
                <property name="databasePlatform" value="org.hibernate.dialect.MySQLInnoDBDialect" />
            </bean>
        </property>
    </bean>
    <!--
    <bean id="dataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource" destroy-method="close">
        <property name="url" value="jdbc:mysql://localhost:3306/database" />
        <property name="user" value="username" />
        <property name="password" value="123456" />
    </bean>
    -->
      <!-- ###### JNDI Lookup ###### -->
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
        <property name="jndiName" value="java:comp/env/jdbc/dbmyapp" />
    </bean>
 
 
 
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    <property name="dataSource" ref="dataSource"/>
  </bean>
 
 
   
    <context:annotation-config/>
    <bean id="basicDao" class="ch.devit.dao.service.BasicDao" />
 
 
    <bean id="surveyService" class="ch.devit.dao.service.SurveyService"
    p:basicDao-ref="basicDao"/>
 
    <bean id="surveyController" class="ch.devit.controller.SurveyController"
    p:userService-ref="surveyService" scope="prototype" />
     
</beans>