maven 常见问题集锦(一)
2011-03-05 12:55
134 查看
一、编译的时候,把依赖的源代码打入jar包,而不仅仅是类文件
mvn eclipse:eclipse -DdownloadSources
二、公司开发的maven插件,生成webx2,webx3,roma等框架的quick-start骨架。
mvn scaffold:create
三、编译时遇到“ 编码 GBK 的不可映射字符 ”错误
添加
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
仍然没有用,最后在maven-compiler-plugin中添加<encoding>utf8</encoding>
得以解决
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>utf8</encoding>
</configuration>
</plugin>
四、maven的jetty插件
http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin
例如:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.18</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<contextPath>/</contextPath>
<scanIntervalSeconds>3</scanIntervalSeconds>
<systemProperties>
<systemProperty>
<name>org.mortbay.jetty.webapp.parentLoaderPriority</name>
<value>true</value>
</systemProperty>
</systemProperties>
</configuration>
<dependencies>
<dependency>
<groupId>javax.j2ee</groupId>
<artifactId>j2ee</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</plugin>
五、maven profile
Profiles
是maven的一个很关键的术语:profile是用来定义一些在build lifecycle中使用的environmental
variations,profile可以设置成在不同的环境下激活不同的profile(例如:不同的OS激活不同的profile,不同的JVM激活
不同的profile,不同的dabase激活不同的profile等等)。
5.1 定义Profiles
你可以把profiles定义在4个地方:
%M2_HOME%/conf/settings.xml,这是针对该部电脑的所有user的profiles,是global profiles,它会影响所有的maven project build
<your -home-directory>/.m2/settings.xml,这是针对per user的profiles,是user级的profiles,它会影响当前user的所有maven project build
定义在pom.xml文件里面,这是仅针对该project的profiles,是project级的profiles
profiles.xml,它和pom.xml在同一个目录下,也是project级的profiles,使用profiles.xml的目的是希望把profiles的设置从pom.xml里抽离出来设置。
pc2.biz上面的profile
<profile>
<id>autoconf</id>
<activation>
<property>
<name>autoconf</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.alibaba.maven.plugins</groupId>
<artifactId>maven-autoconf-plugin</artifactId>
<version>0.3-alpha-7</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>config</goal>
</goals>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</profile>在执行mvn clean install -Pautoconf 激活profile,使得maven-autoconf-plugin生效本文出自 “菜鸟也要修炼技术” 博客,请务必保留此出处http://vicky001.blog.51cto.com/2004660/507208
mvn eclipse:eclipse -DdownloadSources
二、公司开发的maven插件,生成webx2,webx3,roma等框架的quick-start骨架。
mvn scaffold:create
三、编译时遇到“ 编码 GBK 的不可映射字符 ”错误
添加
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
仍然没有用,最后在maven-compiler-plugin中添加<encoding>utf8</encoding>
得以解决
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>utf8</encoding>
</configuration>
</plugin>
四、maven的jetty插件
http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin
例如:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.18</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<contextPath>/</contextPath>
<scanIntervalSeconds>3</scanIntervalSeconds>
<systemProperties>
<systemProperty>
<name>org.mortbay.jetty.webapp.parentLoaderPriority</name>
<value>true</value>
</systemProperty>
</systemProperties>
</configuration>
<dependencies>
<dependency>
<groupId>javax.j2ee</groupId>
<artifactId>j2ee</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</plugin>
五、maven profile
Profiles
是maven的一个很关键的术语:profile是用来定义一些在build lifecycle中使用的environmental
variations,profile可以设置成在不同的环境下激活不同的profile(例如:不同的OS激活不同的profile,不同的JVM激活
不同的profile,不同的dabase激活不同的profile等等)。
5.1 定义Profiles
你可以把profiles定义在4个地方:
%M2_HOME%/conf/settings.xml,这是针对该部电脑的所有user的profiles,是global profiles,它会影响所有的maven project build
<your -home-directory>/.m2/settings.xml,这是针对per user的profiles,是user级的profiles,它会影响当前user的所有maven project build
定义在pom.xml文件里面,这是仅针对该project的profiles,是project级的profiles
profiles.xml,它和pom.xml在同一个目录下,也是project级的profiles,使用profiles.xml的目的是希望把profiles的设置从pom.xml里抽离出来设置。
pc2.biz上面的profile
<profile>
<id>autoconf</id>
<activation>
<property>
<name>autoconf</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.alibaba.maven.plugins</groupId>
<artifactId>maven-autoconf-plugin</artifactId>
<version>0.3-alpha-7</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>config</goal>
</goals>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</profile>在执行mvn clean install -Pautoconf 激活profile,使得maven-autoconf-plugin生效本文出自 “菜鸟也要修炼技术” 博客,请务必保留此出处http://vicky001.blog.51cto.com/2004660/507208
相关文章推荐
- 初学maven(1)-常见小问题集锦
- 【taotao】maven工程常见问题集锦
- Java常见问题集锦25问
- windows域常见问题集锦
- 【ECSHOP二次开发】:常见问题集锦(不定时更新)
- Java常见问题集锦
- maven常见问题问答(含maven属性、变量)
- url等常见问题集锦
- Android面试中常见问题集锦
- [Tips] 开发版常见问题集锦
- maven常见问题问答
- was cached in the local repository, resolution will not be reattempted until(Maven常见问题)
- (转帖)Session常见问题集锦,值得一看
- Maven使用常见问题整理
- 在ASP.NET中使用Session常见问题集锦
- ArcGIS Server常见问题集锦(转载)
- windows域常见问题集锦
- maven常见问题问答
- maven常见问题问答(转)
- Android开发常见问题集锦------持续更新