场景1:在cmd命令行窗口通过maven命令启动web项目,然后通过本机eclipse远程debug调试项目。

场景2:在远程机器cmd命令行窗口通过maven命令启动web项目,然后想通过本机eclipse远程debug调试项目。


第一步:通过cmd命令行进入项目根目录:然后输入命令:mvnDebug Tomcat7:run -Pmysql

(注意:-Pmysql是需要激活我的项目下指定的profile,根据自己项目实际情况选择是否需要输入-P选项参数)

操作如下图:


mvnDebug是maven下的调试运行命令,通过去maven安装目录下的bin目录可查看此命令行脚本文件,

如下图:



打开脚本文件查看调试端口号为8000



执行命令后可看到如下提示: 监听8000端口。此时项目已经运行,并开启了远程调试功能。



第二步  :  配置eclipse远程调试连接。

 通过右击项目pom.xml文件->选择Debug As->选择Debug Configurations...,进入项目配置界面:


选中Remote Java Application 然后选中左上角的新建图标,新建一个Remote Java Application配置

然后在Connect配置标签页依次填入配置名称,远程调试的项目,项目运行主机地址host 以及远程调试端口(就是第一步mavenDebug调试运行监听的端口8000

进入source标签配置页,将项目源码加进来,如下图所示:



之后点击Apply->Debug 即可进行远程调试项目。


第三步:最后在项目中需要断点调试的地方,加入断点,即可进行远程Debug调试。

效果如下图所示:









GitHub 加速计划 / ma / maven
36
2
下载
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:1 个月前 )
9b955261 This commit fixes the regression where resources with a relative targetPath were being copied to the project root instead of relative to the output directory (target/classes or target/test-classes). Changes: 1. DefaultSourceRoot.fromModel: Store targetPath as a relative path instead of resolving it against baseDir and outputDir. This ensures that SourceRoot.targetPath() returns a relative path as intended by the Maven 4 API javadoc. 2. ConnectedResource.computeRelativeTargetPath: Simplified to directly return the relative targetPath from SourceRoot, since it's now always stored as relative. 3. Updated tests to expect relative paths from SourceRoot.targetPath(). Maven 4 API Conformance: - SourceRoot.targetPath() returns an Optional<Path> containing the explicit target path, which should be relative to the output directory (or absolute if explicitly specified as absolute). - SourceRoot.targetPath(Project) resolves this relative path against the project's output directory to produce an absolute path. Maven 3 Compatibility: - Resource.getTargetPath() in Maven 3 was always relative to the output directory. This behavior is preserved by storing targetPath as relative in SourceRoot and converting it back to relative for the Resource API via ConnectedResource. Example: With <targetPath>custom-dir</targetPath>: - Maven 3: Resources copied to target/classes/custom-dir - Maven 4 (before fix): Resources copied to project-root/custom-dir - Maven 4 (after fix): Resources copied to target/classes/custom-dir Fixes #11381 2 天前
83a38634 When using flatten-maven-plugin with updatePomFile=true and parent expansion, Maven incorrectly detected a parent cycle during the install phase. The error occurred because the consumer POM builder was using Path instead of ModelSource when reading the flattened POM. This change updates the PomArtifactTransformer API to use ModelSource instead of Path. ModelSource includes the necessary context (base directory, ModelLocator) to properly resolve parent POMs and avoid false cycle detection. Changes: - Updated PomArtifactTransformer.transform() to accept ModelSource instead of Path - Modified ConsumerPomArtifactTransformer to create ModelSource with proper resolution context - Updated DefaultConsumerPomBuilder and related classes to work with ModelSource - Added integration test to verify the fix Fixes #11399 (cherry picked from commit 5ec059c2d75393aaada2d2c1d0fe0100a1f79554) 2 天前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐