Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29950983
  • 博文数量: 708
  • 博客积分: 12163
  • 博客等级: 上将
  • 技术积分: 8240
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-04 20:59
文章分类

全部博文(708)

分类: Java

2009-11-17 11:13:07

1. How do I prevent including JARs in WEB-INF/lib? I need a "compile only" scope!
2. How do I list available plugins?
3. How do I determine what version of a plugin I am using?
4. How can I use Ant tasks in Maven 2?
5. How do I set up Maven so it will compile with a target and source JVM of my choice?
6. Is it possible to create my own directory structure?
7. Where is the source code? I couldn't seem to find a link anywhere on the Maven2 site.
8. Maven can't seem to download the dependencies. Is my installation correct?
9. I have a jar that I want to put into my local repository. How can I copy it in?
10. How do I unsubscribe from Maven mailing lists?
11. How to skip the tests
12. Handle special characters in site
13. How do I include tools.jar in my dependencies?
14. Why does Maven compile my test classes but don't run them?
15. Where are Maven SNAPSHOT artifacts?
16. Where are the Maven XSD schemas?
17. Maven doesn't work, how do I get help?

1.我如何阻止WEB-INF/lib的JARs文件? 我需要一个"仅编译"的作用范围!
用于这个目的的作用范围已经提供了。这指示Maven,依赖在运行时被它的容器或者JDK提供,举个例子。使用这个作用范围的依赖不会被传递,也不会捆绑到一个包例如WAR中或者包含在运行时的classpath中。

2.我如何列出可用的插件?
"Available Plugins"页列出了他们, 提供了附加的信息来浏览Maven 2 仓库. 参看

3.我如何确定我正在使用的插件版本?
你可以使用Maven帮助插件描述目标。例如,查出安装插件的版本:

mvn -Dplugin=install help:describe
注意你必须给出插件前缀作为插件参数,而不是它的artifact ID.

4.我能够在Maven 2使用Ant的任务吗?

There are currently 2 alternatives:

◎ For use in a plugin written in Java, Beanshell or other Java-like scripting language, you can construct the Ant tasks using the instructions given in the Ant documentation
◎ If you have very small amounts of Ant script specific to your project, you can use the AntRun plugin.


5.我如何设置Maven,使用我选择的JVM源码和目标?

You must configure the source and target parameters in your pom. For example, to set the source and target JVM to 1.5, you should have in your pom :
  1. ...  
  2.   
  3. ...  
  4.      
  5.        
  6.        org.apache.maven.plugins  
  7.        maven-compiler-plugin  
  8.            
  9.            1.5  
  10.            1.5  
  11.            
  12.        
  13.      
  14. ...  
  15.   
  16. ...  
... ... org.apache.maven.plugins maven-compiler-plugin 1.5 1.5 ... ...

6.可以生成我自己的目录结构吗?

Absolutely yes!

By configuring , and other elements of the section.

In addition, you may need to change the plugin configuration if you are not using plugin defaults for their files/directories.

7.源代码在那里? 在Maven2站点我好像没有发现链接.

The source code can be found in subversion:

For more information, see Building Maven 2.0.

8.Maven 好像不能下载依赖. 我的安装不正确吗?

You most probably need to configure Maven to use a proxy. Please see the information on for information on how to configure your proxy for Maven.

9.我有一个jar,我想把它放在我自己本地仓库.我怎样把它拷贝进去?

If you understand the layout of the maven repository, you can copy the jar directly into where it is meant to go. Maven will find this file next time it is run.

If you are not confident about the layout of the maven repository, then you can adapt the following command to load in your jar file, all on one line.
  1. mvn install:install-file  
  2.    -Dfile=  
  3.    -DgroupId=  
  4.    -DartifactId=  
  5.    -Dversion=  
  6.    -Dpackaging=  
  7.    -DgeneratePom=true  
  8.   
  9. Where:    the path to the file to load  
  10.               the group that the file should be registered under  
  11.           the artifact name for the file  
  12.               the version of the file  
  13.             the packaging of the file e.g. jar  
  14.        
mvn install:install-file -Dfile= -DgroupId= -DartifactId= -Dversion= -Dpackaging= -DgeneratePom=true Where: the path to the file to load the group that the file should be registered under the artifact name for the file the version of the file the packaging of the file e.g. jar
This should load in the file into the maven repository, renaming it as needed.

10.我如何取消Maven邮件列表的订约?

To unsubscribe from a Maven mailing list you simply send a message to

[mailing-list]-unsubscribe@maven.apache.org

So, if you have subscribed to then you would send a message to in order to get off the list. People tend to have problems when they subscribe with one address and attempt to unsubscribe with another. So make sure that you are using the same address when unsubscribing that you used to subscribe before asking for help.

If you find you still cannot get off a list then send a message to [mailing-list]-help@maven.apache.org. These instructions are also appended to every message sent out on a maven mailing list ...

11.我如何跳过测试
Add the parameter -Dmaven.test.skip=true in the command line

12.处理站点中特别字符

Configure your ide to use the correct encoding. With eclipse, add -Dfile.encoding=ISO-8859-1 in eclipse.ini file

Configure the output encoding in your pom
  1. ...  
  2.   
  3.    org.apache.maven.plugins  
  4.    maven-site-plugin  
  5.      
  6.      UTF-8  
  7.   
  8. lt;/plugin>  
  9. ...  
... org.apache.maven.plugins maven-site-plugin UTF-8 ...
Configure the file encoding use by mvn. add to MAVEN_OPTS the encoding (same as the ide). This can be made with adding MAVEN_OPTS="-Dfile.encoding=ISO-8859-1" in $HOME/.profile

13.在我的依赖中如何包含tools.jar?

The following code includes tools.jar on Sun JDKs (it is already included in the runtime for Mac OS X and some free JDKs).
  1. ...  
  2.      
  3.        
  4.        default-tools.jar  
  5.          
  6.            
  7.            java.vendor  
  8.            Sun Microsystems Inc.  
  9.          
  10.        
  11.          
  12.            
  13.            com.sun  
  14.            tools  
  15.            1.4.2  
  16.            system  
  17.            ${java.home}/../lib/tools.jar  
  18.          
  19.        
  20.      
  21.   
  22.    ...  
... default-tools.jar java.vendor Sun Microsystems Inc. com.sun tools 1.4.2 system ${java.home}/../lib/tools.jar ...

14.为啥Maven编译了我测试类但不运行他们?

Tests are run by the surefire plugin. The surefire plugin can be configured to run certain test classes and you may have unintentionally done so by specifying a value to ${test}. Check your settings.xml and pom.xml for a property named "test" which would like this:
  1.    ...  
  2.      
  3.        
  4.        test  
  5.        some-value  
  6.        
  7.   
  8.    ...  
  9.   
  10. or  
  11.   
  12.    ...  
  13.      
  14.      some-value  
  15.   
  16.    ...  
... test some-value ... or ... some-value ...

15.Where are Maven SNAPSHOT artifacts?

If you are trying to build a development version of Maven or plugins, you may need to access the maven snapshot repositories.

You need to update your settings.xml file using the Guide to Plugin Snapshot Repositories

16.那里是Maven XSD模式?

The Maven XSD is located and the Maven Settings XSD is located .

Your favorite IDE probably supports XSD schema's for pom.xml and settings.xml editing. You need to specify the following:
  1. ""  
  2.    xmlns:xsi=""  
  3.    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  
  4.                        http://maven.apache.org/maven-v4_0_0.xsd">  
  5.   
  6.    ...  
  7.   
  8.   
  9. ""  
  10.    xmlns:xsi=""  
  11.    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  
  12.                        http://maven.apache.org/xsd/settings-1.0.0.xsd">  
  13.    ...  
  14.   
... ...

17.Maven 不工作,我如何获得帮助?

We have compiled a list of available resources on the
阅读(1827) | 评论(0) | 转发(0) |
0

上一篇:Maven持续集成最佳实践

下一篇:Apache Ivy

给主人留下些什么吧!~~