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

如何为phantomjs-maven-plugin传命令行参数?遇ssl-protocol报错

Fixing "Invalid values for 'ssl-protocol' option" in phantomjs-maven-plugin

It looks like the issue comes down to how you're passing command-line options to the plugin. Using a single space-separated string for commandLineOptions can lead to incorrect parsing, which is why you're seeing the invalid value error for ssl-protocol.

Here's the corrected configuration that should resolve the problem:

<plugin>
    <groupId>com.github.klieber</groupId>
    <artifactId>phantomjs-maven-plugin</artifactId>
    <version>0.7</version>
    <executions>
        <execution>
            <phase>integration-test</phase>
            <goals>
                <goal>install</goal>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <version>2.1.1</version>
        <checkSystemPath>true</checkSystemPath>
        <!-- Split each command-line option into its own <option> element -->
        <commandLineOptions>
            <option>--ssl-protocol=any</option>
            <option>--ignore-ssl-errors</option>
        </commandLineOptions>
        <script>assets/test.js</script>
        <arguments>
            <argument>${liberty.https.server.port}</argument>
        </arguments>
    </configuration>
</plugin>

Why this works:

The phantomjs-maven-plugin handles individual <option> elements far more reliably than a single concatenated string. By splitting your SSL-related flags into separate entries, you ensure the plugin passes them as distinct command-line arguments to PhantomJS—exactly matching the manual command you want to replicate:

phantomjs --ssl-protocol=any --ignore-ssl-errors test.js ${liberty.https.server.port}

Quick validation checks:

  • PhantomJS 2.1.1 does support --ssl-protocol=any (this option was added to let the binary auto-negotiate the best SSL/TLS version, so it's valid for your chosen version).
  • Double-check for typos in option names (e.g., confirm --ignore-ssl-errors is spelled correctly—no missing hyphens or misspellings).

After updating your pom.xml with this configuration, re-run your Maven integration test phase. This should eliminate the invalid option error and execute your script with the desired SSL settings.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 06:32:34