相关疑难解决方法(0)

Java Web应用程序配置模式

是否有任何模式或最佳实践可用于简化跨多个环境的Java Web应用程序的配置配置文件更改.例如JDBC URL,SOAP端点等.

作为帮助澄清我的问题的一些背景知识,我使用了几个大型的Java Web应用程序,这些应用程序在任何给定的发布周期中都可以通过6个不同的环境; 开发,集成,QA,性能并最终部署到多个生产服务器.在每个环境中,配置都需要更改.目前,每个部署的大多数配置更改都是手动完成的,这既费时又容易出错.
有没有办法从这个过程中进行人工干预?

java configuration design-patterns web-applications

60
推荐指数
4
解决办法
2万
查看次数

属性文件中的Persistence.xml字段值

求助,我想将我的持久性xml属性值引用到我的db.properties文件中.

这是我的db.properties文件

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/apsas
jdbc.username=root
jdbc.password=password
Run Code Online (Sandbox Code Playgroud)

这是我当前的persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">
    <persistence-unit name="apsaspu" transaction-type="RESOURCE_LOCAL">
        <provider>
            org.hibernate.ejb.HibernatePersistence
        </provider>
        <properties>
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/apsas" />
            <property name="hibernate.connection.username" value="root" />
            <property name="hibernate.connection.password" value="password" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
        </properties>
    </persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)

我想要做的是将其属性设置为这样

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">
    <persistence-unit name="apsaspu" transaction-type="RESOURCE_LOCAL">
        <provider>
            org.hibernate.ejb.HibernatePersistence
        </provider>
        <properties>
            <property name="hibernate.connection.driver_class" value="${jdbc.driver}" />
            <property name="hibernate.connection.url" value="${jdbc.url}" />
            <property …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa properties persistence.xml

7
推荐指数
1
解决办法
6431
查看次数