English 中文(简体)
• 如何用Xml文档中具有实际价值的变数取代Maven的另一份依赖性杰尔案
原标题:How to substitute a variable with real value in a xml file , which is in another dependency jar file by Maven
  • 时间:2011-06-17 17:25:42
  •  标签:
  • java
  • maven

我们有一个称为网络申请1的项目,依靠另一个称为核心申请的杰尔档案,这个档案由另一个小组作为共享图书馆提供,但在这个核心申请.jar(在杰尔一侧)中,有一只藏书,内容如下。

<hibernate-configuration>
    <session-factory>
        <property name="dialect">${hibernate.dialect}</property>
        <property name="query.substitutions"><![CDATA[false  N , true  Y ]]></property>
        <property name="show_sql">false</property>
        <property name="format_sql">false</property>
        <property name="use_sql_comments">false</property>
        <property name="generate_statistics">true</property>
        <property name="hibernate.connection.release_mode">after_transaction</property>
       <!-- Search Configurations -->
        <property name="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</property>
        <property name="hibernate.search.default.indexBase">${lucene.index.home}</property>
        <property name="hibernate.search.default.batch.merge_factor">10</property>
        <property name="hibernate.search.default.batch.max_buffered_docs">10</property>
    </session-factory>
</hibernate-configuration>

As we see in the Search Configurations section, there is a variable ${lucene.index.home} that should be replaced by other projects on different OS platform,
so the question, does maven provide a way to filter a dependency jar file and filter the content? any plugins ? war:war , unzip ? dependencies ? I couldn t figure a fast way to do that. it looks to me , no matter what plugin would be adopted, the plugin needs to do 4 things basically.

  • 1 unpack the jar in process-resources phase.
  • 2 substitute the ${var} with value defined in profile.
  • 3 pack it again back into a jar.
  • 4 need to copy it back from the packing/unpacking workspace back to the maven process path ??

以前,任何人都符合这一类似要求。

感谢

问题回答

我将假设这些数值是打算暂时确定的,很可能是作为证书的论点。 提供必须经过修改才能使用的jar档案是没有意义的。

如果你真的需要为配置目的在建筑时间进行过滤,那么这些配置文件就应当过滤,而NOT是你的属性。 那么,你要么把手工艺交给多种手工艺品(当然,你以多种环境为目标),要么在建筑工艺之外作为外部化的资源提供。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签