为啥 Hybris 发布不安全的 http maven 存储库 URL?为啥我们不能覆盖它?

Posted

技术标签:

【中文标题】为啥 Hybris 发布不安全的 http maven 存储库 URL?为啥我们不能覆盖它?【英文标题】:Why does Hybris ship insecure http maven repository URL? And why can't we override it?为什么 Hybris 发布不安全的 http maven 存储库 URL?为什么我们不能覆盖它? 【发布时间】:2020-05-15 06:35:15 【问题描述】:

apache-ant/lib/libraries.properties

m2.repo=http://repo1.maven.org/maven2/

发送带有http URL的Hybris有什么意义?首先无法访问,更不用说用于下载了。 理想情况下,它应该是一个https URL。

m2.repo=https://repo1.maven.org/maven2/

我尝试通过在local.properties 中重新声明此属性来覆盖它。当它没有选择新值时,我在apache-ant/lib/libraries.properties 中将其更改为https,但它仍在选择http。如何覆盖这个属性?

错误日志:

[artifact:mvn] Downloading: org/apache/maven/apache-maven/3.2.5/apache-maven-3.2.5.pom from repository central at http://repo1.maven.org/maven2
[artifact:mvn] Error transferring file: Operation timed out (Connection timed out)
[artifact:mvn] [WARNING] Unable to get resource 'org.apache.maven:apache-maven:pom:3.2.5' from repository central (http://repo1.maven.org/maven2): Error transferring file: Operation timed out (Connection timed out)
     [null] An error has occurred while processing the Maven artifact tasks.
     [null]  Diagnosis:
     [null] 
     [null] Unable to resolve artifact: Missing:
     [null] ----------
     [null] 1) org.apache.maven:apache-maven:pom:3.2.5
     [null]   Path to dependency: 
     [null]     1) org.apache.maven:super-pom:pom:2.0
     [null]     2) org.apache.maven:apache-maven:pom:3.2.5
     [null] 
     [null] ----------
     [null] 1 required artifact is missing.
     [null] 
     [null] for artifact: 
     [null]   org.apache.maven:super-pom:pom:2.0
     [null] 
     [null] from the specified remote repositories:
     [null]   central (http://repo1.maven.org/maven2)
     [null] 
     [null] 

BUILD FAILED

【问题讨论】:

伟大的发现! +1 发布。 【参考方案1】:

local.properties 中重新声明 m2.repo 将不起作用,因为 Hybris 没有加载此类属性。您可以通过在 hAC > Platform > Configuration 中搜索 m2.repo(或直接在 https://localhost:9002/platform/config)中进行验证。

如果您执行ant,在apache-ant/lib/libraries.properties 中修改它应该可以工作。如果不是这样,请告诉我,我会尝试找到其他选项。

当没有选择新值时,我将其更改为https in apache-ant/lib/libraries.properties,但它仍在选择 http。如何 覆盖这个属性?

如果您提及您在哪里看到它选择http,将会很有帮助。请提及复制此行为的步骤。

【讨论】:

很高兴收到您的来信,先生......我们在美敦力合作过......我在ant clean all的最后一行收到错误......当我设置@ 987654333@作为属性之一..... 真是一个惊喜!我几次看到你的名字但认不出你,因为你没有在DP上用过你自己的照片。我希望你做得很好,我相信你一定是你团队的资产。祝你事业有成!回到您的问题,当我在自定义扩展中更新external-dependendencies.xml 并在其extensioninfo.xml 中更改usemaven=true 时,我能够在我的系统中复制该问题。然后,我尝试了Neil Hubert-Price 提供的解决方案,它奏效了。请务必接受他的回答,以便其他人也可以放心使用。 answers.sap.com/questions/12957190/…也已回复【参考方案2】:

您可以通过设置 $HOME/.m2/settings.xml 文件来覆盖它。

例如:

    <?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <profiles>
        <profile>
            <id>default</id>
            <repositories>
                <repository>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                    <id>central</id>
                    <url>https://repo1.maven.org/maven2</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                    <id>central</id>
                    <url>https://repo1.maven.org/maven2</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>default</activeProfile>
    </activeProfiles>

</settings>

【讨论】:

以上是关于为啥 Hybris 发布不安全的 http maven 存储库 URL?为啥我们不能覆盖它?的主要内容,如果未能解决你的问题,请参考以下文章

如何更改 Hybris 服务器的端口

ffmpeg——压缩mav格式音频

SAP Commerce/Hybris 升级多个版本

http中的put,delete等请求为啥不安全

为啥单击文本框垃圾结果的报告?

Hybris 后台:WYSIWYG 中的图像配置不起作用