maven使用遇到的问题
2017-01-12 本文已影响0人
百炼
[TOC]
【Maven】快速走进Maven的世界
1. maven deploy tomcat
参考:Maven入门示例(3):自动部署至外部Tomcat
maven web项目通过插件实现热部署到Tomcat
部署javaweb到tomcat
conf/tomcat-user.xml配置tomcat密码
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="s3cret" roles="manager-gui,manager-script"/>
2. 安装本地jar包 到maven环境的执行语句:
mvn install:install-file -DgroupId=com.test.tanyy -DartifactId=sinaWeibo -Dversion=1.0 -Dpackaging=jar -Dfile=E:\sinaWeibo.jar
mvn install:install-file -DgroupId=com.test.tanyy -DartifactId=qqLoginSdk4J -Dversion=1.0 -Dpackaging=jar -Dfile=E:\qqLoginSdk4J.jar
mvn install:install-file -DgroupId=com.test.tanyy -DartifactId=QRCode -Dversion=1.0 -Dpackaging=jar -Dfile=E:\QRCode.jar
3. Maven 阿里仓库
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
4. Maven 使用JDK1.7 构建(eclipse 添加后要选择Maven -> Update Project)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
5. Maven 部署到jetty
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.26</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<useTestClasspath>true</useTestClasspath>
<webAppConfig>
<contextPath>/SSM</contextPath>
</webAppConfig>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
</connector>
</connectors>
</configuration>
</plugin>
6. maven打sources.jar包
plugins下加入maven-source-plugin并且绑定到package生命周期,运行mvn clean package即可打sources.jar包
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
- 使用本地
jar
<dependencies>
<dependency>
<groupId>com.ydj</groupId>
<artifactId>servlet</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>D:/code/IdeaProjects/HowTomcatWorks/lib/servlet.jar</systemPath>
</dependency>
<dependency>
<groupId>com.ydj</groupId>
<artifactId>how-tomcat-works-util</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>D:/code/IdeaProjects/HowTomcatWorks/lib/how-tomcat-works-util-0.0.1-SNAPSHOT.jar</systemPath>
</dependency>
</dependencies>