Maven使用
1.提示某些java语言特性不支持,这可能是由于maven默认使用的java compiler的版本太低所致,需在pom的<build>中添加maven-compiler-plugin
31 <plugin> 32 <groupId>org.apache.maven.plugins</groupId> 33 <artifactId>maven-compiler-plugin</artifactId> 34 <configuration> 35 <source>1.6</source> 36 <target>1.6</target> 37 </configuration> 38 </plugin>
2.注意pom文件中定义dependency时的scope是compile还是provided
3.maven的源代码中,关于dependency:tree这一部分的实现的代码,觉得写得不错,计划后面看,分为graph与tree两个版本?
just interested in how maven pom resolve transitive dependencies
BFS的形式?
4.maven
<optional>true</optional>
详细见https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
是在使用rose上传的功能,遇到与http://www.mkyong.com/struts/java-lang-noclassdeffounderror-orgapachecommonsiooutputdeferredfileoutputstream/
类似的问题时候,排查查到的
从而需要单独添加对commons-io的依赖
5.maven新建工程
mvn archetype:create -DgroupId=groupId -DartifactId=projectName -Dversion=1.0.0 -DpackageName=com.renren.ad
6.maven调试
出错需要进行调试的时候加上一个-x
7.正常使用时需要的插件
70 <build> 71 <plugins> 72 <plugin> 73 <groupId>org.apache.maven.plugins</groupId> 74 <artifactId>maven-compiler-plugin</artifactId> 75 <configuration> 76 <source>1.6</source> 77 <target>1.6</target> 78 <verbose>true</verbose> 79 <encoding>UTF-8</encoding> 80 <compilerArguments> 81 <sourcepath>${project.basedir}/src/main/java</sourcepath> 82 </compilerArguments> 83 </configuration> 84 </plugin> 85 <plugin> 86 <groupId>org.apache.maven.plugins</groupId> 87 <artifactId>maven-resources-plugin</artifactId> 88 <configuration> 89 <encoding>UTF-8</encoding> 90 </configuration> 91 </plugin> 92 </plugins> 93 <resources> 94 <resource> 95 <directory>${project.basedir}/src/main/resources</directory> 96 </resource> 97 </resources> 98 </build>
在这个之前的,即文件的开头需要如下配置
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 <modelVersion>4.0.0</modelVersion> 4 5 <groupId>com.xxx.xxx</groupId> 6 <artifactId>logxxxxxxx</artifactId> 7 <version>1.0-SNAPSHOT</version> 8 <packaging>jar</packaging> 9 10 <name>logxxxxxxxx</name> 11 <url>http://maven.apache.org</url> 12 13 <properties> 14 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 15 </properties> 16 17 <parent> 18 <groupId>com.xxxxxx</groupId> 19 <artifactId>xxxxxxx-root-pom</artifactId> 20 <version>1.0-SNAPSHOT</version> 21 </parent> 22 23 <dependencies> 24 ...... 25 </dependencies>
8.maven插件
maven-assembly-plugin
128 <plugin> 129 <groupId>org.apache.maven.plugins</groupId> 130 <artifactId>maven-assembly-plugin</artifactId> 131 <version>2.4.1</version> 132 <configuration> 133 <!--get all project dependencies--> 134 <descriptorRefs> 135 <descriptorRef>jar-with-dependencies</descriptorRef> 136 </descriptorRefs> 137 </configuration> 138 <executions> 139 <execution> 140 <id>make-assembly</id> 141 <!--bind to package phase--> 142 <phase>package</phase> 143 <goals> 144 <goal>single</goal> 145 </goals> 146 </execution> 147 </executions> 148 </plugin>
maven-shade-plugin
150 <plugin> 151 <groupId>org.apache.maven.plugins</groupId> 152 <artifactId>maven-shade-plugin</artifactId> 153 <version>2.4</version> 154 <executions> 155 <execution> 156 <phase>package</phase> 157 <goals> 158 <goal>shade</goal> 159 </goals> 160 <configuration> 161 <relocations> 162 <relocation> 163 <pattern>org.apache.thrift</pattern> 164 <shadedPattern>org.shaded.thrift</shadedPattern> 165 </relocation> 166 </relocations> 167 </configuration> 168 </execution> 169 </executions> 170 </plugin>
用于class relocation https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html
http://www.boyunjian.com/do/article/snapshot.do?uid=684161795280089944
http://www.infoq.com/cn/news/2011/06/xxb-maven-9-package/
http://www.cnblogs.com/xinsheng/p/4109573.html
http://blog.csdn.net/thc1987/article/details/44176481
http://zfei.me/blog/2014/05/23/use-maven-shade-plugin-to-resolve-java-dependency-version-conflict/
relocate时候将package和import涉及到的lib的package都改变了。
jarjar
https://www.mail-archive.com/user@hive.apache.org/msg09819.html
http://grokbase.com/t/hive/user/13aaptne38/is-that-possible-to-use-hive-0-11-with-libthrift-0-7