You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何不修改pom.xml通过Maven命令以debug模式编译项目?

可以通过命令传参实现,不需要修改生产环境使用的pom.xml默认配置,有两种常用实现方式:

方案1:直接传递编译参数(无需修改pom.xml)

直接在执行打包命令时追加两个编译参数即可临时开启debug模式编译:

mvn clean package -Dmaven.compiler.debug=true -Dmaven.compiler.debuglevel=lines,vars,source

该方式适合偶发扫描的场景,生产环境正常执行原打包命令即可,不会生成带debug信息的包,完全无侵入。

方案2:配置专用Profile(适合频繁扫描场景)

如果需要经常执行Veracode扫描,不想每次输入长参数,可以在pom.xml中新增一个专属配置Profile,默认不激活:

<profiles>
  <profile>
    <id>veracode-scan</id>
    <build>
      <plugins>
        <plugin> 
          <artifactId>maven-compiler-plugin</artifactId> 
          <configuration>
            <debug>true</debug>
            <debuglevel>lines,vars,source</debuglevel>
          </configuration>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

扫描时执行命令激活Profile即可:

mvn clean package -Pveracode-scan

生产环境打包不加-P参数,默认不会激活该Profile,不会影响生产包的编译配置。

内容的提问来源于stack exchange,提问作者Saif

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 16:24:03