<title>Build a MAVEN project with MyEclipse-My long program journey-Blogjava</title>Here is the Myeclpise's own maven plugin.
MAVEN is best configured as the one you installed yourself, and MyEclipse comes with some bugs.
With Nexus Agent Maven's central repository, the Setting.xml configuration file is modified as follows:
<Mirrors>
?????<Mirror>
??????????<ID>Nexus</ID>
??????????<mirrorof>*</mirrorof>
??????????<name>Nexus? Mirror</name>
??????????<URL>Http://localhost:8081/nexus/content/groups/public</URL>
?????</Mirror>
??</Mirrors>
??
??<Profiles>
?????< Profile>
??????<ID>Nexus</ID>
??????<repositories>
????????<Repository>
??????????<ID>Central</ID>
??????????<URL>Http://central</URL>
??????????<releases><enabled>True</enabled></releases>
??????????<Snapshots><enabled>True</enabled></Snapshots>
????????</Repository>
??????</repositories>
?????<pluginrepositories>
????????<pluginrepository>
??????????<ID>Central</ID>
??????????<URL>Http://central</URL>
??????????<releases><enabled>True</enabled></releases>
??????????<Snapshots><enabled>True</enabled></Snapshots>
????????</pluginrepository>
??????</pluginrepositories>
????</ Profile>
??</Profiles>
??<Activeprofiles>
????<Activeprofile>Nexus</Activeprofile>
??</Activeprofiles>Http://localhost:8081/nexus/content/groups/public? is the address of the Warehouse group.
Lay the interface for MyEclipse New project and choose Maven Project under Maven to open the wizard as follows:
Here we will check create a simple project.
Click Next to fill in the Gav related content.
When you click Done, we have successfully created a MAVEN project.
The default directory structure for the project is as follows:
All of the Java source files are written in the Src/main/java directory, and all the test classes are written under Src/test/java, which is the default value for Maven.
At this point, only the default attributes in Pom.xml
<project?xmlns= "http://maven.apache.org/POM/4.0.0"? xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"? xsi:schemalocation= "Http://maven.apache.org/POM/4.0.0?http://maven.apache.org/maven-v4_0_0.xsd">
??<modelversion>4.0.0</modelversion>
??<groupId>Com.test</groupId>
??<Artifactid>Test</Artifactid>
??<version>0.0.1-snapshot</version>
</Project>This is the most streamlined pom.xml.
At this point we join JUnit's support and create a new test class.
Right-click on the item Maven-add Dependency to display the following interface:
Enter JUnit to join the test support class library.
Create a new test class under Src/test/java as follows:
Package Com;import Org.junit.test;public Class testrun{@Testpublic void TestA (){SYSTEM.OUT.PRINTLN ("Test a Method");}@Testpublic void Testb (){System.out.println ("Test B method");}} Right-click Run as-----Maven test and test it to show the following results:
[INFO]? Scanning? for? projects
[INFO]?????????????????????????????????????????????????????????????????????????
[INFO]?------------------------------------------------------------------------
[INFO]? Building?test?0.0.1-snapshot
[INFO]?------------------------------------------------------------------------
[INFO]?
[INFO]?---? maven-resources-plugin:2.5:resources? (default-resources) [Email protected]?test?---
[Debug]?execute?contextualize
[WARNING]? Using?platform?encoding? (gbk?actually)? to?copy?filtered?resources,?i.e.?build?is?platform?dependent!
[INFO]? Copying?0?resource
[INFO]?
[INFO]?---? maven-compiler-plugin:2.3.2:compile? (default-compile) [Email protected]?test?---
[INFO]? Nothing?to?compile?-? All?classes?are?up?to?date
[INFO]?
[INFO]?---? maven-resources-plugin:2.5:testresources? (default-testresources) [Email protected]?test?---
[Debug]?execute?contextualize
[WARNING]? Using?platform?encoding? (gbk?actually)? to?copy?filtered?resources,?i.e.?build?is?platform?dependent!
[INFO]? Copying?0?resource
[INFO]?
[INFO]?---? maven-compiler-plugin:2.3.2:testcompile? (default-testcompile) [Email protected]?test?---
[INFO]? Nothing?to?compile?-? All?classes?are?up?to?date
[INFO]?
[INFO]?---? maven-surefire-plugin:2.10:test? (default-test) [Email protected]?test?---
[INFO]? Surefire?report?directory:? D:\workspace\test\target\surefire-reports
-------------------------------------------------------
? T? E? S? T? S
-------------------------------------------------------
Running?com. TestRun
Test?a?method?
Test?b?method?
Tests?run:?2, huh? Failures:?0, huh? Errors:?0, huh? Skipped:?0, huh? Time?elapsed:?0.071?sec
Results?:
Tests?run:?2, huh? Failures:?0, huh? Errors:?0, huh? Skipped:?0
[INFO]?------------------------------------------------------------------------
[INFO]? BUILD? SUCCESS
[INFO]?------------------------------------------------------------------------
[INFO]? Total?time:?1.847s
[INFO]? Finished?at:? Tue? Sep?11?14:20:59? cst?2012
[INFO]? Final? memory:?3m/6m
[INFO]?------------------------------------------------------------------------OK, a basic MAVEN project has been built. We can also convert existing Java projects into MAVEN project using Myclipse, which we'll discuss in the next section.
From for notes (Wiz)
Build a MAVEN project with MyEclipse-My long program journey-Blogjava