1.设置服务器java vm的-agentlib:jdwp选项.
[server]
//windwos
//set JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=8888,server=y,suspend=n
//linux
export HADOOP_CLIENT_OPTS=-agentlib:jdwp=transport=dt_socket,address=8888,server=y,suspend=y
2.在server启动java程序
hadoop jar HdfsDemo.jar com.it18zhang.hdfs.mr.compress.TestCompress
3.server会暂挂在8888.
Listening ...
4.客户端通过远程调试连接到远程主机的8888.
5.客户端就可以调试了。
在pom.xml中引入新的插件(maven-antrun-plugin),实现文件的复制.
-------------------------------------------------------------
[pom.xml]
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>---------开始复制jar包到共享目录下----------</echo>
<delete file="E:\shareCentos\hdfsExample-1.0-SNAPSHOT.jar"></delete>
<copy file="target\hdfsExample-1.0-SNAPSHOT.jar" toFile="E:\shareCentos\HdfsDemo.jar">
</copy>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>