日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SAP Commerce配置属性的优先级

發布時間:2023/12/19 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SAP Commerce配置属性的优先级 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

https://help.sap.com/viewer/b490bb4e85bc42a7aa09d513d0bcb18e/1905/en-US/8b8e13c9866910149d40b151a9196543.html

優先級從高到低:

  • The local.properties file
  • Extension-specific project.properties files
  • The global project.properties file (that is, the project.properties file in the <${HYBRIS_BIN_DIR}/platform> directory)

  • 這張表一目了然:

    不推薦修改platform文件夾下面的project.properties文件,原因如下:

  • Commerce升級時,這個文件的內容會被覆蓋。
  • 在生產場景里,可能根本不具備這個文件所在的文件夾的修改權限。
  • 如何在代碼里訪問properties

    SAP Commerce properties are provided in the global ApplicationContext. With this, you can inject a specific value by using the usual Spring notation:

    <bean class="Foo"><property name="bar" value="${key_of_property}"/> </bean>

    The properties are provided by PropertyPlaceholderConfigurer with hybrisPropertiesConfigurer id, which gets the hybrisProperties bean injected. This bean fulfills the java.util.Properties class and holds all properties. You can use this bean in other scenarios too, especially if you want to use the SAP Commerce properties in your WebApplicationContext, having the global ApplicationContext as a parent. For this, define:

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="properties" ref="hybrisProperties"/> </bean>

    關于ref的用法,可以參考這個例子:

    BankService類:

    Account是一個接口,有set和get方法。

    bean.xml:

    <beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd"><bean id="accountDetails" class="com.jwt.spring.AccountImpl" /><bean id="bankservice" class="com.jwt.spring.BankService"><property name="accdetails"><ref bean="accountDetails" /></property></bean></beans>

    Be aware that this mechanism is not tenant aware. You always get the properties of the master tenant and you do not recognize changes to properties done at runtime. As the configurator is a BeanFactoryPostProcessor, it gets applied once at a startup of a context.

    測試代碼:

    package com.jwt.spring;import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;public class Test {public static void main(String[] args) {ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");BankService bankSer = (BankService) context.getBean("bankservice");bankSer.withdraw(1000000, 2000.00);bankSer.deposit(1000000, 2000.00);} }

    ServiceLayer的訪問方式:

    On the ServiceLayer, SAP Commerce configuration is reachable using the ConfigurationService. Calling the getConfiguration() method returns a Configuration object. By factory default implementation, the returned object is a HybrisConfiguration object, as shown in the UML diagram.

    最佳實踐

    A common practice to override property values is to copy individual properties from the project.properties and to paste them into the local.properties file with an edited value.

    可以利用JVM的啟動參數:

    java -Dfoo=“some string” SomeClass

    等價于:
    This is the equivalent to adding the following lines to the local.properties file, but the VM parameters are runtime only:

    db.url=jdbc:mysql://localhost/trunk?useConfigs=maxPerformance&characterEncoding=utf8 db.driver=com.mysql.jdbc.Driver db.username=root db.password=root

    要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":

    總結

    以上是生活随笔為你收集整理的SAP Commerce配置属性的优先级的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。