I. Determining the dependency relationship
The entire project is divided into three parts:
Parent:pom, responsible for aggregating the entire project and determining the version of all jar packages.
Common:jar package, place generic components, tool classes.
Manage:pom, responsible for aggregating the background of the web, Service,mapper,pojo.
Second, MAVEN configuration
Unzip maven and configure it to environment variables. Refer to: http://blog.csdn.net/wangmei4968/article/details/50086411
Create a MAVEN project based on dependencies and configure the XML file.
In the parent Pom file, the version number of all jar packages is placed.
The contents are as follows:
<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/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <parent> <groupId>com.taotao</groupId> < Artifactid>taotao-parent</artifactid> <version>0.0.1-SNAPSHOT</version> </parent> < Groupid>com.taotao</groupid> <artifactId>taotao-common</artifactId> <version>0.0.1- Snapshot</version> <!--jar Package Dependent-<dependencies> <!---time action component--><dependency>< groupid>joda-time</groupid><artifactid>joda-time</artifactid></dependency><!-- Apache Tools Component--><dependency><groupid>org.apache.commons</groupid><artifactid> commons-lang3</artifactid></dependency><dependency><groupid>org.apache.commons</ Groupid><artifactid>commons-io</artifactid></dependency><dependency><groupid>commons-net </groupId><artifactId>commons-net</artifactId></dependency><!--Jackson JSON processing toolkit-- ><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId> jackson-databind</artifactid></dependency><!--httpclient--><dependency><groupid> Org.apache.httpcomponents</groupid><artifactid>httpclient</artifactid></dependency> <!--unit Test--><dependency><groupid>junit</groupid><artifactid>junit</artifactid ><scope>test</scope></dependency><!--Log Processing--><dependency><groupid> Org.slf4j</groupid><artifactid>slf4j-log4j12</artifactid></dependency> </ Dependencies></project>
The
common Pom files are mainly placed on time operations, Apache tools, JSON processing tools, httpclient, unit tests, and log processing tools.
<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/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <parent> <groupId>com.taotao</groupId> < Artifactid>taotao-parent</artifactid> <version>0.0.1-SNAPSHOT</version> </parent> < Groupid>com.taotao</groupid> <artifactId>taotao-common</artifactId> <version>0.0.1- Snapshot</version> <!--jar Package Dependent-<dependencies> <!---time action component--><dependency>< groupid>joda-time</groupid><artifactid>joda-time</artifactid></dependency><!-- Apache Tools Component--><dependency><groupid>org.apache.commons</groupid><artifactid> commons-lang3</artifactid></dependency><dependency><groupid>org.apache.commons</ Groupid><artifactid>commons-io</artifactid></dependency><dependency><groupid>commons-net </groupId><artifactId>commons-net</artifactId></dependency><!--Jackson JSON processing toolkit-- ><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId> jackson-databind</artifactid></dependency><!--httpclient--><dependency><groupid> Org.apache.httpcomponents</groupid><artifactid>httpclient</artifactid></dependency> <!--unit Test--><dependency><groupid>junit</groupid><artifactid>junit</artifactid ><scope>test</scope></dependency><!--Log Processing--><dependency><groupid> Org.slf4j</groupid><artifactid>slf4j-log4j12</artifactid></dependency> </ Dependencies></project>
The
manager Pom file, which is primarily dependency management, configures the Tomcat plugin. when creating a child of the manager, the MAVEN model is created.
<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/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <parent> <groupId>com.taotao</groupId> < Artifactid>taotao-parent</artifactid> <version>0.0.1-SNAPSHOT</version> </parent> < Groupid>com.taotao</groupid> <artifactId>taotao-manager</artifactId> <version>0.0.1- Snapshot</version> <packaging>pom</packaging> <!--dependency Management--<dependencies> <depend ency> <groupId>com.taotao</groupId> <artifactId>taotao-common</artifactId> <version >0.0.1-SNAPSHOT</version> </dependency> </dependencies> <modules> <module> Taotao-manager-pojo</module> <module>taotao-manager-mapper</module> <module>taotao-manager-service</module> <module>taotao-manager-web</module> </modules > <!--configuration plug-in <build> <plugins><!--Configuring the Tomcat plugin--><plugin><groupid>org.apa Che.tomcat.maven</groupid><artifactid>tomcat7-maven-plugin</artifactid><configuration> <port>8080</port><path>/</path></configuration></plugin> </plugins> </build></project>
The
mapper Pom file primarily prevents dependency management, MySQL, connection pooling information.
<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/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <parent> <groupId>com.taotao</groupId> < Artifactid>taotao-manager</artifactid> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>taotao-manager-mapper</artifactId> <!--Dependency Management--<dependencies> <dependency& Gt <groupId>com.taotao</groupId> <artifactId>taotao-manager-pojo</artifactId> <version >0.0.1-SNAPSHOT</version> </dependency> <!--Mybatis--><dependency><groupid> org.mybatis</groupid><artifactid>mybatis</artifactid><version>${mybatis.version}</ version></dependency><dependency><groupid>org.mybatis</groupid><artifactid>mybatis-spring</artifactid><version>${mybatis.spring.version}</version></ Dependency><dependency><groupid>com.github.miemiedev</groupid><artifactid> Mybatis-paginator</artifactid><version>${mybatis.paginator.version}</version></dependency ><dependency><groupid>com.github.pagehelper</groupid><artifactid>pagehelper</ artifactid><version>${pagehelper.version}</version></dependency><!--MySql-->< Dependency><groupid>mysql</groupid><artifactid>mysql-connector-java</artifactid> <version>${mysql.version}</version></dependency><!--Connection Pool--><dependency>< Groupid>com.alibaba</groupid><artifactid>druid</artifactid><version>${druid.version }</version></dependency> </dependencies></project>
In the
servcie Pom, the main configuration relies on management, and there are some spring configurations.
<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/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <parent> <groupId>com.taotao</groupId> < Artifactid>taotao-manager</artifactid> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>taotao-manager-service</artifactId> <!--Dependency Management--<dependencies> <dependency > <groupId>com.taotao</groupId> <artifactId>taotao-manager-mapper</artifactId> < Version>0.0.1-snapshot</version> </dependency> <!--Spring--><dependency><groupid >org.springframework</groupId><artifactId>spring-context</artifactId></dependency> <dependency><groupid>org.springframework</groupid><artifactid>spring-beans</artifactId></dependency><dependency><groupId>org.springframework</groupId>< Artifactid>spring-webmvc</artifactid></dependency><dependency><groupid> org.springframework</groupid><artifactid>spring-jdbc</artifactid></dependency>< dependency><groupid>org.springframework</groupid><artifactid>spring-aspects</ Artifactid></dependency> </dependencies></project>
Pojo inside the basic need not configure what information.
<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/xsd/maven-4.0.0.xsd" > < modelversion>4.0.0</modelversion> <parent> <groupId>com.taotao</groupId> <artifactId>taotao-manager</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>taotao-manager-pojo</artifactId></project>
After the configuration is complete, maven Clean,install, if the intermediate code is not down, you can view the. m2 inside the settings.xml file
<?xml version= "1.0" encoding= "UTF-8" standalone= "no"? ><settings xmlns= "http://maven.apache.org/SETTINGS/ 1.0.0 "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://maven.apache.org/ settings/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd "><!--set the local warehouse path--><localrepository>d :\taotaoproject\repository</localrepository><!--set user name and secret--><servers><server> when releasing the jar package <id>releases</id><username>admin</username><password>admin123</password> </server><server><id>snapshots</id><username>admin</username><password >admin123</password></server></servers><!--setting up MAVEN's remote repository for Nexus--><mirrors>< Mirror> <id>nexus</id><mirrorof>central</mirrorof><name>nexus repository</ Name><url>http://192.168.22.246:8081/nexus/content/groups/public</url></mirror> <!-- <mirror> <id>CN</id> <name>oschina central</name> <url>http://maven.oschina.net/content/gro ups/public/</url> <mirrorOf>central</mirrorOf> </mirror>--></mirrors><!--settings The path of Central, etc.--><profiles><profile><id>central</id><repositories><repository ><id>central</id><name>central</name><url>http://192.168.22.246:8081/nexus/ content/groups/public</url></repository></repositories><pluginrepositories>< pluginrepository><id>central</id><name>central</name><url>http:// 192.168.22.246:8081/nexus/content/groups/public</url></pluginrepository></pluginrepositories ></profile> </profiles><activeProfiles> <activeprofile>central</activeprofile></activeprofiles><!--Configuring the Eclipse plug-in--><plugingroups><plugingroup>org.mortbay.jetty</ Plugingroup><plugingroup>org.codehaus.cargo</plugingroup><plugingroup> Org.jvnet.hudson.tools</plugingroup></plugingroups></settings>
Http://192.168.22.246:8081/nexus/content/groups/public is the address of the IP, you can go in to see if there is a jar package, the jar package version is correct.
Maven Common commands:
Maven clean, clears the resulting project
Maven Install, compiling
Maven test, run the tests
Maven generate-sources. Generate any additional source code required by the application
Download the jar package via install here, select Maven Build, enter the clean tomcat7:run, and start with your own Tomcat plugin.
Five, SVN management
Install the SVN client with three directories:
Branches: Branch, 5.0 nodes, with bug,6.0 in progress, need to check out the branch and make changes.
Trunk: Trunk, general development code.
When uploading the code, right-click the project, choose Team--share project--Create the repository (from the SVN copy URL path)-To do svn correlation.
In team synchronizing view, to Ingnore *.project,*.settings.xml,*.classpath,*.target file, submit Pom, src,src/site file.
This file only needs to submit common,manager,parent, because the relationship has been configured in the manager, so you can directly submit MANAGER,SVN there are other files. But if you want to edit the module, add the MAVEN exist model, such as the Web, Mapper, and so on.
Taotao--maven Frame Construction Ideas (spents 1 pm +1 nights)