Maven POM文件配置示例
排除传递性依赖
1 2 3 4 5 6 7 8 9 10 11 12 |
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>2.5.0</version> <exclusions> <exclusion> <!-- CXF对Spring-web的依赖被排除 --> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </exclusion> </exclusions> </dependency> |
指定资源文件目录并过滤
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<build> <directory>target</directory> <outputDirectory>target/classes</outputDirectory> <testOutputDirectory>target/test-classes</testOutputDirectory> <sourceDirectory>src/main/java</sourceDirectory> <testSourceDirectory>src/test/java</testSourceDirectory> <resources> <resource> <!-- 在这里可以指定多个资源文件目录 --> <directory>src/main/java</directory> <excludes> <!--注意该配置从本应当是源代码的目录中过滤掉Java文件,其他文件作为资源文件 --> <exclude>**/*.java</exclude> </excludes> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> <testResources> <testResource> <directory>src/test/resources</directory> </testResource> </testResources> </build> |
指定额外的源代码目录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>src/birt/java</source> <source>src/cms/java</source> </sources> </configuration> </execution> </executions> </plugin> |
过滤资源文件
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<build> <resources> <resource> <!-- 启用src/main/resources的资源过滤 --> <filtering>true</filtering> <directory>src/main/resources</directory> <excludes> <!-- 排除资源文件 --> <exclude>application-${environment}.properties</exclude> </excludes> </resource> </resources> </build> |
配置目录链接(Linked Folder)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.10</version> <configuration> <linkedResources> <linkedResource> <name>src/main/webapp</name> <type>2</type> <location>D:/www</location> </linkedResource> </linkedResources> </configuration> </plugin> |
打包时生成*–sources.jar
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<plugin> <artifactId>maven-source-plugin</artifactId> <version>2.2.1</version> <configuration> <attach>true</attach> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> |
打包时生成*–javadoc.jar
1 2 3 4 5 6 7 8 9 10 11 12 |
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> |
指定编译级别
1 2 3 4 5 6 7 8 9 10 |
<plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.4</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> <source>1.5</source> <target>1.5</target> <debug>true</debug> </configuration> </plugin> |
启用对AspectJ的支持
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>aspectj-maven-plugin</artifactId> <version>1.4</version> <executions> <execution> <id>compile</id> <configuration> <XnoInline>true</XnoInline> <forceAjcCompile>true</forceAjcCompile> <showWeaveInfo>true</showWeaveInfo> <source>1.5</source> <target>1.5</target> <encoding>UTF-8</encoding> <verbose>true</verbose> <outxml>true</outxml> <aspectLibraries> <aspectLibrary> <!--下面的构件同时需要在dependency里面配置--> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> </aspectLibrary> </aspectLibraries> </configuration> <goals> <goal>compile</goal> <goal>test-compile</goal> </goals> </execution> </executions> </plugin> |
指定源代码、资源文件的编码方式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.4</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> |
打包时拷贝所有依赖包
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<plugin> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions> <execution> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin> |
打包生成可执行的jar文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <archive> <manifest> <mainClass>cc.gmem.common.Application</mainClass> </manifest> </archive> <appendAssemblyId>true</appendAssemblyId> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </execution> </executions> </plugin> |
打uber-jar另一种方法
maven-shade-plugin也支持将依赖打包进JAR,这类似于maven-assembly-plugin。但是后者存在BUG,会导致Unable to locate Spring NamespaceHandler for XML schema namespace这样的错误。
除了打包指外,maven-shade-plugin还具有重命名(Shade)功能 —— 修改某些包名。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.1.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <!-- 禁止生成dependency-reduced-pom.xml --> <createDependencyReducedPom>false</createDependencyReducedPom> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> </transformers> <filters> <!-- 解决报错:Invalid signature file digest for Manifest main attributes --> <filter> <artifact>*:*</artifact> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin> |
使用profile打带分类器(classifer)的jar包
1 2 |
#分类器打包命令示例 mvn clean jar -P jdk15 |
1 2 3 4 5 6 7 |
<!-- 引用带分类器的构件 --> <dependency> <groupId>cc.gmem.tools</groupId> <artifactId>cmd-tools</artifactId> <version>1.0</version> <classifier>jdk15</classifier> </dependency> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
<project> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <encoding>UTF-8</encoding> <source>${jar.source}</source> <target>${jar.target}</target> </configuration> </plugin> </plugins> </build> <!-- 执行mvn命令时,使用-P参数激活某个profile --> <profiles> <profile> <id>default</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <jar.source>1.6</jar.source> <jar.target>1.6</jar.target> </properties> </profile> <profile> <id>jdk15</id> <build> <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <classifier>jdk15</classifier> </configuration> </execution> </executions> </plugin> </plugins> </build> <properties> <jar.source>1.5</jar.source> <jar.target>1.5</jar.target> </properties> </profile> <profile> <id>jdk14</id> <build> <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <classifier>jdk14</classifier> </configuration> </execution> </executions> </plugin> </plugins> </build> <properties> <jar.source>1.4</jar.source> <jar.target>1.4</jar.target> </properties> </profile> </profiles> </project> |
执行Junit测试控制台输出乱码问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.15</version> <dependencies> <dependency> <groupId> org.apache.maven.surefire</groupId> <artifactId> surefire-junit47</artifactId> <version> 2.15</ version> </dependency> </dependencies> <configuration> <argLine> -Dfile.encoding=UTF-8</argLine> </configuration> </plugin> |
将war构件中的Java类独立打包
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <!-- 下面的配置参数导致所有Java类被打包到一个JAR文件,并嵌入在WEB-INF/LIB下 --> <archiveClasses>true</archiveClasses> <!-- 下面的配置参数导致所有Java类被导报到一个JAR文件,并作为额外的构件看待 该构件的名称为[groupId].[artifactId].[version]-classes.jar 其它项目可以通过分类器classes来引用此JAR: <groupId>myGroup</groupId> <artifactId>myArtifact</artifactId> <version>myVersion</myVersion> <classifier>classes</classifier> --> <attachClasses>true</attachClasses> <!-- 上述额外构件的分类器字段的名称,默认classes --> <classesClassifier>classes</classesClassifier> </configuration> </plugin> |
将多个war包构件的内容合并到一个中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<dependencies> <dependency> <groupId>cc.gmem.secmon</groupId> <artifactId>map</artifactId> <version>0.0.1-SNAPSHOT</version> <type>war</type> <scope>runtime</scope> <!-- 以这种方式声明war依赖后,当前项目打包后,该war包的全部内容都会叠加进去--> </dependency> </dependencies> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <overlays> <!-- 使用下面的配置,可以指定war运行时依赖中,哪些内容需要被排除出去 --> <!--下面的构件同时需要在dependency里面配置--> <overlay> <groupId>cc.gmem.secmon</groupId> <artifactId>map</artifactId> <excludes> <exclude>WEB-INF/lib/sshe-*.jar</exclude><!-- 通配单个目录或者文件的一部分 --> <exclude>WEB-INF/classes/**/*.class</exclude> <!-- 双星号通配任意层目录 --> </excludes> </overlay> <overlay> <groupId>cc.gmem.secmon</groupId> <artifactId>intelli</artifactId> <excludes> <exclude>WEB-INF/lib/comm-tools-*.jar</exclude> </excludes> </overlay> </overlays> </configuration> </plugin> |
指定Maven仓库的位置,在mvn deploy时用到
1 2 3 4 5 6 7 8 9 10 |
<distributionManagement> <repository> <id>nexus</id> <url>http://192.168.0.200:8801/nexus/content/repositories/releases</url> </repository> <snapshotRepository> <id>nexus</id> <url>http://192.168.0.200:8801/nexus/content/repositories/snapshots</url> </snapshotRepository> </distributionManagement> |
注:在org.apache.maven.plugins:maven-deploy-plugin:2.8.2版本之后,不配置distributionManagement也可以mvn deploy,可以通过命令行指定远程仓库的信息。使用如下系统属性即可:
1 2 3 |
# id::layout::url -DaltReleaseDeploymentRepository=pa-releases::default::https://nexus.pacloud.io/repository/maven-releases/ -DaltSnapshotDeploymentRepository=pa-snapshots::default::https://nexus.pacloud.io/repository/maven-snapshots/ |
压缩和混淆JavaScript代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<plugin> <groupId>net.alchim31.maven</groupId> <artifactId>yuicompressor-maven-plugin</artifactId> <version>1.5.1</version> <executions> <execution> <phase>process-resources</phase><!-- 注意,该阶段在Emvn package -Pproclipse中会自动运行,一旦你保存源码,就会执行压缩 --> <goals> <goal>compress</goal> </goals> </execution> </executions> <configuration> <nosuffix>true</nosuffix> <!-- 输出js是否不带-min.js后缀 --> <!-- 压缩文件存放目录 --> <webappDirectory>${project.build.directory}/compressed</webappDirectory> <jswarn>false</jswarn> <!-- 是否显示警告信息 --> <nocompress>false</nocompress><!-- 是否压缩 --> <nomunge>false</nomunge><!-- 是否进行代码混淆 --> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <webResources> <resource> <!-- 这里必须引用压缩文件存放目录 --> <directory>${project.build.directory}/compressed</directory> </resource> </webResources> </configuration> </plugin> |
上面的配置,在Eclipse中会导致每次保存JavaScript文件都执行压缩,这会影响性能,因此可以使用Maven的Profile机制,仅在打包时启用压缩,下面是一个例子:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <overlays> <overlay> <groupId>cc.gmem.study</groupId> <artifactId>obfuscate-module</artifactId> <excludes> <exclude>WEB-INF/classes/**/*.class</exclude> </excludes> </overlay> </overlays> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>production</id> <properties> <yui.compressed.dir>${project.build.directory}/compressed</yui.compressed.dir> </properties> <build> <plugins> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>yuicompressor-maven-plugin</artifactId> <version>1.5.1</version> <executions> <execution> <phase>process-resources</phase> <goals> <goal>compress</goal> </goals> </execution> </executions> <configuration> <nosuffix>true</nosuffix> <!-- 输出js是否不带-min.js后缀 --> <!-- 压缩文件存放目录 --> <webappDirectory>${yui.compressed.dir}</webappDirectory> <jswarn>false</jswarn> <!-- 是否显示警告信息 --> <nocompress>false</nocompress><!-- 是否压缩 --> <nomunge>false</nomunge><!-- 是否进行代码混淆 --> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <!-- overlays的配置会从默认Profile继承,不需要再次声明 --> <webResources> <resource> <!-- 这里必须引用压缩文件存放目录 --> <directory>${yui.compressed.dir}</directory> </resource> </webResources> </configuration> </plugin> </plugins> </build> </profile> </profiles> |
压缩和混淆Java代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
<plugin> <groupId>com.github.wvengen</groupId> <artifactId>proguard-maven-plugin</artifactId> <version>2.0.8</version> <dependencies> <dependency> <groupId>net.sf.proguard</groupId> <artifactId>proguard-base</artifactId> <version>5.2</version> <scope>runtime</scope> </dependency> </dependencies> <executions> <execution> <!-- 注意,不会对maven-war-plugin通过overlay得到的类进行任何处理,此时war已经打包完毕 --> <phase>package</phase> <goals> <goal>proguard</goal> </goals> <configuration> <!-- 从文件读取ProGuard配置选项 --> <proguardInclude>${project.basedir}/.proguard</proguardInclude> <!-- 直接指定ProGuard配置选项 --> <options> <option>-keep public class * { public protected *; }</option> <option>-dontoptimize</option> </options> <!-- 以下ProGuard选项自动设置: -dontobfuscate,如果配置obfuscate -verbose,如果以-X运行Maven --> <!-- JVM库一般不在Maven依赖列表中 --> <libs> <lib>${java.home}/lib/rt.jar</lib> <lib>${java.home}/lib/jsse.jar</lib> </libs> <!-- 是否把Maven依赖作为库看待,默认true --> <includeDependency>true</includeDependency> <!-- 当启用includeDependency时,进行细粒度的过滤控制 --> <exclusions> <exclusion> <groupId>javax.inject</groupId> <artifactId>javax.inject</artifactId> </exclusion> </exclusions> <!-- 执行代码混淆--> <obfuscate>true</obfuscate> <!-- START 下面的配置,将把编译阶段得出的classes拷贝daoclasses_proguard_base, 然后把daoclasses_proguard_base作为输入目录;把classes作为输出目录 --> <!-- 输入文件设置为编译好的target/classes目录 --> <injar>classes</injar> <!-- 不匹配下面过滤器的文件,不会被处理,也不会进入classes --> <inFilter>!cc/gmem/study/obfuscate/keep/**</inFilter> <!-- END --> <!-- START 如上配置,如果加上下面这行设置,则classes保持编译阶段的原样, 处理后的结果存放到processed-classes --> <outjar>processed-classes</outjar> <!-- END --> </configuration> </execution> </executions> </plugin> |
使用Spring、Hibernate的工程,混淆配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<execution> <phase>process-classes</phase> <goals> <goal>proguard</goal> </goals> <configuration> <injar>classes</injar> <options> <option> -libraryjars ${java.home}/lib/rt.jar -keep public class * { public protected *; } -keepparameternames #例如SpringMVC,可能依赖于方法参数的名称 -keepattributes Exceptions,InnerClasses,Signature,*Annotation*,EnclosingMethod -keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve(); } -keepclassmembers class * { @javax.annotation.Resource *; } -keepclassmembers class * { @javax.inject.Inject *; } -keepclassmembers class * { @org.springframework.beans.factory.annotation.Autowired *; } </option> </options> </configuration> </execution> |
spring boot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.0.0.RELEASE</version> <configuration> <!-- 指定入口点 --> <mainClass>com.dangdang.digital.spring.data.redis.Application</mainClass> <layout>JAR</layout> <!-- 将主资源文件目录加入到classpath中 --> <addResources>true</addResources> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <!-- 打自包含包 mvn clean package -P boot 运行程序 mvn spring-boot:run -P boot --> |
集成docker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <version>1.4.7</version> <executions> <execution> <id>default</id> <goals> <goal>build</goal> <goal>push</goal> </goals> </execution> </executions> <configuration> <!-- Docker上下文目录,寻找其中的Dockerfile文件,不支持非Dockerfile的文件名 --> <contextDirectory>.</contextDirectory> <!-- 打包的Docker镜像名称 --> <repository>docker.gmem.cc/prometheus/dubbo_exporter</repository> <tag>${project.version}</tag> <!-- 构建时参数,必须在Dockerfile中声明对应的ARG --> <buildArgs> <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> </plugin> |
集成helm
该插件支持打包、部署、删除,不支持和Chart仓库交互。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<plugin> <groupId>org.microbean</groupId> <artifactId>helm-maven-plugin</artifactId> <version>2.8.2.1.1.1</version> <executions> <execution> <id>default</id> <phase>package</phase> <goals> <goal>package</goal> </goals> <configuration> <!-- Chart定义存在的目录 --> <chartContentsUri>file:${project.basedir}/.chart</chartContentsUri> <!-- 打包后的Chart存放位置 --> <chartTargetUri>file:${project.build.directory}/charts/${project.artifactId}.tgz</chartTargetUri> </configuration> </execution> </executions> </plugin> |
集成bash
1 2 3 4 5 6 7 8 9 10 11 |
<plugin> <groupId>com.atlassian.maven.plugins</groupId> <artifactId>bash-maven-plugin</artifactId> <version>1.0-SNAPSHOT</version> <configuration> <script> helm delete dubbo-exporter --purge helm install target/charts/dubbo_exporter.tgz --name=dubbo-exporter </script> </configuration> </plugin> |
Groovy + Java 联合
添加插件仓库:
1 2 3 4 5 6 7 8 9 10 11 |
<pluginRepository> <id>bintray</id> <name>Groovy Bintray</name> <url>https://dl.bintray.com/groovy/maven</url> <releases> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> |
添加插件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <compilerId>groovy-eclipse-compiler</compilerId> </configuration> <dependencies> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-compiler</artifactId> <version>3.3.0-01</version> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-batch</artifactId> <version>2.5.6-01</version> </dependency> </dependencies> </plugin> |
Groovy的依赖仍然需要添加:
1 2 3 4 5 6 |
<dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy</artifactId> <classifier>indy</classifier> <version>2.5.6</version> </dependency> |
关于源码目录结构:
- 默认情况下,可以把所有Groovy代码都放到src/main/java目录
- 如果src/main/java下至少有一个文件,则可以将Groovy代码放到src/main/groovy目录
Leave a Reply