Académique Documents
Professionnel Documents
Culture Documents
1. To check whether maven installed properly or not , type the following command
mvn --version
2. Create a project
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
or
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app
or
mvn archetype:generate
3. COMPILE
A). For simple java Application
a.) compile the resources( .properties file) if present
mvn process-resources
b.) compile application sources
mvn compile
4. Build project
a) mvn package
or
maven jar
b) mvn package -Dmaven.test.failure.ignore=true
or
mvn package -Dmaven.skip=true
5. To install the jar
a) mvn install
b) using command line
mvn install -Dmaven.test.failure.ignore=true
or
mvn install -Dmaven.skip=true
c)
maven.junit.fork=true
To install the jar file manually
mvn install:install-file -DgroupId=jini -DartifactId=mahalo \
-Dversion=2.1 -Dpackaging=jar -Dfile=/path/to/file
eg.
mvn install:install-file -DgroupId=junit -DartifactId=junit -Dversion=4.3.1 -Dpa
ckaging=jar -Dfile=D:\ganesh_works\All_Jars\BS-project-jars\junit-4.3.1.jar
6. Now test the newly compiled and packaged JAR with the following command:
a) To run the file manually
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
b) Executing the application
mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main
11. This can be run over the top of a previous IDEA project - it will update the
settings rather than starting fresh.
If you are using Eclipse IDE, just call:
mvn eclipse:eclipse
12. Uninstalling maven
Remove the folder in which maven in installed.
1. Now run mvn -N install in daytrader/ in order to install the parent POM in yo
ur local
repository and make it available to all modules:
C:\dev\m2book\code\j2ee\daytrader>mvn -N install
Now we are ready to develop to generate the sub-projects .
2. go to C:\dev\m2book\code\j2ee\daytrader\wsappclient>
The location of WSDL source can be customized using the sourceDirectory property
.
In order to generate the Java source files from the TradeServices.wsdl file, the
wsappclient/pom.xml file must declare and configure the Axis Tools plugin
<project>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
As before, you need to add the J2EE specifications JAR to compile the project's
Java sources. Thus
the following three dependencies have been added to your POM:
1. axis
2. axis-jaxrpc
3. geronimo-j2ee_1.4_spec
4. activation
5. mail
6.
<dependencies>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee_1.4_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Also u need to manually install the activation and mail jar.
3. now run the following command
mvn install
eg.
C:\dev\m2book\code\j2ee\daytrader\wsappclient>mvn install
4.
b)
In order to generate the Java source files from the TradeServices.wsdl file, th
e
wsappclient/pom.xml file must declare and configure the Axis Tools plugin
<project>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java2wsdl</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
various ways to make web services
1.Axis2 tools maven plugin
plugins : axistools-maven-plugin
dependencies : 1. axis
2. axis-jaxrpc
3. geronimo-j2ee_1.4_spec
install the below two jars manually
4. activation
5. mail
eg.
<plugins>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java2wsdl</goal> or wsdl2java
</goals>
</execution>
</executions>
<configuration>
<sourceDirectory>
src/main/resources/META-INF/wsdl
</sourceDirectory>
</configuration>
</plugin>
</plugins>
<dependencies>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee_1.4_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>