簡體   English   中英

jboss-web.xml可以訪問屬性嗎?

[英]Can jboss-web.xml have access to properties?

我正在嘗試將我的項目設置為根據環境使用不同的虛擬主機名。

我知道我可以在每個目錄中使用單獨的jboss-web.xml文件創建目錄。 但我最近將這個項目移到了maven,並希望利用這些配置文件。 我已經設置了數據庫,因此可以使用過濾器通過配置文件對它們進行不同的配置。

的jboss-web.xml中:

<jboss-web>
    <context-root>/</context-root>
    <virtual-host>${jbossweb.virtualhost}</virtual-host>
</jboss-web>

特定於環境的屬性文件具有以下條目:

jbossweb.virtualhost=hostname.domain.com

pom文件構建部分具有此定義

    <filters>
        <filter>src/main/filters/filter-${env}.properties</filter>
    </filters>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
        <resource>
            <directory>src/main/webapp/WEB-INF</directory>
            <filtering>true</filtering>
        </resource>
    </resources>

只是為了衡量,配置文件部分具有以下配置:

  <profile>
    <id>dev</id>
    <properties>
      <env>dev</env>
    </properties>
  </profile>

我甚至不確定我想做的事情是否可行。 當我嘗試它時,Jboss-web.xml在虛擬主機位置具有變量名稱而不是值。

我吠叫錯了樹嗎?

謝謝,

埃里克

實際上,我發現了一種方法:

jboss-web.xml現在看起來像這樣:

<jboss-web>
    <context-root>${jbossweb.contextroot}</context-root>
    <virtual-host>${jbossweb.virtualhost}</virtual-host>
 </jboss-web>

屬性文件如下所示:

 jbossweb.virtualhost=hostname
 jbossweb.contextroot=/

然后pom部分對於maven war插件配置看起來像這樣:

                <webResources>
                    <resource>
                        <directory>src/main/webapp/WEB-INF</directory>
                        <filtering>true</filtering>
                        <include>jboss-web.xml</include>
                        <targetPath>/WEB-INF</targetPath>
                    </resource>
                </webResources>

過濾器在插件部分上方定義,但在構建部分內如下:

    <filters>
        <filter>src/main/filters/filter-${env}.properties</filter>
    </filters>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM