Maven手记

本文介绍了在Windows XP系统下安装Maven的详细步骤。包括下载Maven、双击exe文件指定目录安装,检查并设置环境变量,可选步骤创建本地依赖库,最后重启系统,还可通过命令验证安装是否正确。

作者:monkito email:seeker(at)zmaze.org

windows XP下的安装:

1.下载Maven(http://maven.apache.org/start/download.html)。

2.双击exe安装文件,指定目录安装。所指定的目录路径请不要有中文,也请尽量避免空格;(我曾经遇到因为空格导致设置不成功的倒霉事儿)

3.检查环境变量。命令行下输入echo %maven_home%,输出的地址应该是指向Maven安装目录的地址,此目录下应该直接可以看到/bin/、/lib、/plugins三个目录以及其他文件等。如果没有输入安装目录的地址,请用命令set maven_home=...设置。同时,你也需要在Path变量中加入指向%MAVEN_HOME%/bin的地址;

4.下面的步骤可选,且可能只对2000以上系统有效:在命令行下输入命令%MAVEN_HOME%/bin/install_repo.bat %HOME%/.maven/repository(注意:%HOME%地址指的是你的用户在系统盘的主目录,例如我的就是C:/Documents and Settings/monkito)。此语句会创建本地依赖库。如果跳过此步骤也没有关系,Maven会通过下载来代替从lib目录复制依赖库;

5.重启系统后,你的Maven就可以正常使用了。你可以通过在命令行中输入maven -v命令来验证是否安装正确。

原文出处:http://www.zmaze.org/drupal/?q=node/view/95

当你在Maven项目中操作Excel文件,依然可以利用Apache POI库。在Maven项目中,你需要在pom.xml文件中添加相应的POI依赖,例如: ```xml <dependencies> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>5.0.0</version> <!-- 更新至最新稳定版本 --> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>5.0.0</version> <!-- 可能还需要poi核心库,取决于具体需求 --> </dependency> </dependencies> ``` 然后,你可以在代码中按照之前提供的步骤,导入所需的包并编写读取和合并Excel文件的逻辑。Maven的依赖管理会自动处理库的引入和版本更新。 例如,你可以创建一个Maven插件或者在src/main/java目录下编写一个Java类,用来遍历指定目录下的Excel文件,并执行数据提取和合并: ```java import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.poi.ss.usermodel.*; public class ExcelMergeMojo extends AbstractMojo { private final String directoryPath; public ExcelMergeMojo(String directoryPath) { this.directoryPath = directoryPath; } @Override public void execute() throws MojoExecutionException { File dir = new File(directoryPath); if (!dir.exists()) { getLog().warn("Directory not found: " + directoryPath); return; } // 搜索并处理Excel文件 for (File file : dir.listFiles((dir1, name) -> name.endsWith(".xls") || name.endsWith(".xlsx"))) { mergeData(file.getAbsolutePath()); } } private void mergeData(String filePath) { // 根据之前提到的`extractData`函数,处理单个文件 // ... } } ``` 然后,在你的pom.xml文件中配置此插件: ```xml <build> <plugins> <plugin> <groupId>com.mycompany</groupId> <artifactId>excel-merge-maven-plugin</artifactId> <version>1.0-SNAPSHOT</version> <executions> <execution> <id>merge-excel-files</id> <phase>process-resources</phase> <goals> <goal>merge</goal> </goals> <configuration> <directoryPath>${project.build.directory}/input</directoryPath> <!-- 输入目录 --> </configuration> </execution> </executions> </plugin> </plugins> </build> ``` 这只是一个基础的例子,实际应用可能会根据你的具体需求有所不同,比如错误处理、并发处理等。记得在运行前确认Apache POI的版本是否满足项目的需要。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值