赞
踩
一、工程目录
dac_parent 父目录
dac-utils 继承 dac_parent(不依赖 dac_parent)
dac-csr 依赖 dac_parent
dac-label 依赖 dac_parent 和 dac-csr
dac-test 依赖 dac_parent 和 dac-utils
二、实际操作
新建project名称,其中底部是module名称
删除src文件,修改pom
<groupId>com.lhx.bigdata</groupId>
<artifactId>dac-parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>../dac-csr</module>
<module>../dac-label</module>
<module>../dac-test</module>
</modules>
<dependencies>
省略。。。
</dependencies>
</project>
选中dac-parent右键
使用maven直接Next
新建dac-utils模块
点击右上角… 选中none
选中dac-parent右键
新建dac-csr dac-label dac-test模块
修改dac-utils的pom
<parent>
<artifactId>dac-parent</artifactId>
<groupId>com.lhx.bigdata</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../dac-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dac-utils</artifactId>
<build>
省略。。。
</build>
</project>
修改dac-label的pom
<parent> <artifactId>dac-parent</artifactId> <groupId>com.lhx.bigdata</groupId> <version>1.0-SNAPSHOT</version> <relativePath>../dac-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>dac-label</artifactId> <packaging>pom</packaging> <dependencies> <dependency> <groupId>com.lhx.bigdata</groupId> <artifactId>dac-csr</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <build> 省略。。。 </build> </project>
修改dac-test的pom
<parent> <artifactId>dac-parent</artifactId> <groupId>com.lhx.bigdata</groupId> <version>1.0-SNAPSHOT</version> <relativePath>../dac-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>dac-test</artifactId> <dependencies> <dependency> <groupId>com.lhx.bigdata</groupId> <artifactId>dac-utils</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <build> 省略。。。 </build> </project>
三、新建测试代码
(1) dac-utils代码
object DateUtil {
def getNowTime(dateFormat:String): String = {
val ca = Calendar.getInstance
val resultDate:Date = ca.getTime()
val sdf:SimpleDateFormat = new SimpleDateFormat(dateFormat)
sdf.format(resultDate)
}
}
(2) dac-test代码
package test
import baseutils.DateUtil
object TestDemo {
def main(args: Array[String]): Unit = {
val date = DateUtil.getNowTime("yyyy-MM-dd")
println("date=="+date)
}
}
运行打包
先把dac-utils注册到本地maven库(点击dac-utils右键Build Module,然后再执行Lifecycle -> install)
再把dac-test打包(点击dac-test右键Build Module,然后再执行Plugins-> assembly)
(或者把全部模块注册到本地maven库Lifecycle -> install)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。