"Maven" Maven+myeclipse build

Source: Internet
Author: User

Environment: win7+myeclipse8.6+maven3.2.1

Installing MAVEN

1. Download maven, unzip to directory D;

2. Configure the MAVEN environment variable: maven_home; add path variable;

3. DOS Input mvn-version Test setup is successful, if present, then success;

Modify the Local warehouse

The local repository is a remote download jar from your configuration, and the default local repository is under the C-drive user directory. m2\repository

1. Go to Maven's installation directory Conf/setting.xml add the following code. At this point, the local repository is changed to the following directory.

< localrepository > C:\Users\Administrator\06_maven\apache-maven-3.2.1\maven_jar</localrepository> 

Configure Maven+myeclipse

Go to MyEclipse's window->pReferences window to the left to see a maven option.

  Click Installations, select the Add button on the right, and choose Maven installed on your machine.

  Then click on user Settings, set user Settings, select%maven_home%\conf\settings.xml, then update

The Association of the MyEclipse and maven, maven repositories is set up at this point.

View window-->preferences-->java-->build Path-->classpath variables Find the M2_repo, the path is the path to the local warehouse.

Create a MAVEN-style Web project

1. new->others->maven->maven project.

Using the default workspace path, the path does not need to be defined under the path you want to specify.

Select Maven-archetype-webapp, which indicates that you are creating a Web project, or select Maven-archetype-quickstart if you want to create a generic Java project.

Set the GroupID, Artifactid, and package names.

A MAVEN project is now ready.

The project path is built as follows:

  

2. Add the Src/main/java source folder to store my Java files and set up a src/main/test to store the test class.

3. Specify the location of the class file output.

Right-click the project name, select Properties (last), select javabuildpath->source-Select one, and fill in the target/classes. The Java bytecode file is now all stored under target/classes.

4. Configure Tomcat to embed this plugin into our project using Tomcat-maven-plugin.

The inline method is to add the following code inside the Pox.xml

<Build>    <Finalname>MyTest</Finalname>    <Plugins>            <plugin>                <groupId>Org.codehaus.mojo</groupId>                <Artifactid>Tomcat-maven-plugin</Artifactid><!--designationTomcat Plugin -                <version>1.1</version>                <executions>                    <Execution>                        <ID>Tomcat-deploy</ID>                        <Phase>Deploy</Phase>                        <Goals>                            <goal>Deploy</goal>                        </Goals>                    </Execution>                </executions>                <Configuration>                    <Path>/</Path><!--Access Path -                    <Port>8080</Port><!--Port number -                    <warsourcedirectory>Src/main/webapp</warsourcedirectory><!--This is the equivalent of specifying our usual Webroot path, the following is the path of Web. XML -                    <Tomcatwebxml>Src/main/webapp/web-inf/web.xml</Tomcatwebxml>                </Configuration>            </plugin>        </Plugins>  </Build>

  So Tomcat-maven-plugin has been configured.

5. Configure three startup parameters.

Run As->run Configurations->maven Build. This adds MAVEN's compilation, packaging, and tomcat boot three parameters.

Maven Build right-click New, create a new name compile, add main parameter clean compile-e;

Maven Build right-click New, create a new name package, add main parameter package;

Maven Build right-click New, create a new name tomcat, add main parameter tomcat:run;

The above three base directory are: ${workspace_loc:/mytest}

6. run the configured compile command first, then run the Package command, and run Tomcat last. At this point, Tomcat is running up.

What Tomcat is running at this time? Info inside: Running War on http://localhost:8080/, is it necessary to copy the war to tomcat under boot?

"The whole process of attention to see MyEclipse the following information, if wrong, must see error Analysis"

7. Locate the war packet in target and copy it to Tomcat's WebApps to start Tomcat. Enter localhost:8080\mytest\ and you can view it. This is the Web project published with the war.

Summary of errors that occurred:

1. Out of Bounds exception information: Could not get Mojo execution paramater value

Plugin org.apache.maven.plugins:maven-compiler-plugin:2.0.2 or one of its dependencies could not be resolved:missing:

Cause of error: missing maven-compiler-plugin:2.0.2. Then I went to the MAVEN repository and I did not find this jar package, but it was there under. M2.

My solution: Copy the jar package under the. M2.

Here's a question: When was the Maven repository built? What are the principles of construction? Why didn't you have it later? (Online Some people say that the speed caused by the download is not finished)

It is also possible to choose to support maven directly when a new project is used in the lab. Two is the same truth.

   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.