环境变量 DHIS2_HOME: null (TrayApp.java [main])

Environment variable DHIS2_HOME: null (TrayApp.java [main])

在我的 Windows Vista 机器上尝试使用 Postgres 连接启动 dhis2-live.exe 时出现错误 Environment variable DHIS2_HOME: null (TrayApp.java [main])

然而,如果使用 H2 数据库,相同的应用程序运行良好,但根据要求,我需要使用 Postgres

这是日志文件。

* INFO  23:48:27,232 Environment variable DHIS2_HOME: null (TrayApp.java [main])
* INFO  23:48:27,700 Initialising DHIS 2 Live... (TrayApp.java [main])
* INFO  23:48:28,574 Loading DHIS 2 on port: 8082 (WebAppServer.java [main])
* INFO  23:48:28,745 Setting DHIS 2 web app context to: /D:/dhis-live/webapps/dhis (WebAppServer.java [main])
* INFO  23:48:28,745 Lifecycle: server starting (TrayApp.java [Thread-2])
* INFO  23:48:55,001 System property dhis2.home points to /D:/dhis-live/conf (DefaultLocationManager.java [Thread-2])
* INFO  23:49:00,290 Hibernate configuration loaded, using dialect: org.hibernate.dialect.PostgreSQLDialect (DefaultHibernateConfigurationProvider.java [Thread-2])
* INFO  23:50:32,286 Found the following message senders: [org.hisp.dhis.message.EmailMessageSender@c0023f, org.hisp.dhis.sms.SmsMessageSender@b027dd] (DefaultMessageService.java [Thread-2])
* INFO  23:51:25,998 Lifecycle: server started (TrayApp.java [Thread-2])

hibernate.properties

#hibernate.dialect = org.hibernate.dialect.H2Dialect
#hibernate.connection.driver_class = org.h2.Driver
#hibernate.connection.url = jdbc:h2:./database/dhis2;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE
#hibernate.connection.username = sa
#hibernate.connection.password =

hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
hibernate.connection.driver_class = org.postgresql.Driver
hibernate.connection.url = jdbc:postgresql:dhis2
hibernate.connection.username = dhis
hibernate.connection.password = dhis

hibernate.hbm2ddl.auto = update

实际上,TrayApp.java 文件将用于使用我们在 DHIS2_HOME[= 中设置的位置读取初始配置25=]变量。

请按照以下步骤操作:

  1. 用你所在位置的值创建一个 DHIS2_HOME 系统变量,如 D:\dhis2
  2. 使用以下配置在此位置创建 hibernate.properties 文件

    hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
    hibernate.connection.driver_class = org.postgresql.Driver
    hibernate.connection.url = jdbc:postgresql:dhis2
    hibernate.connection.username = dhis
    hibernate.connection.password = dhis
    hibernate.hbm2ddl.auto = update

现在单击 dhis2-live.exe 以使用 posgresql 启动 dhis2 应用程序。

希望对您有所帮助!!

@Ranjitsinh 的回答可能对未来的某些读者有所帮助,但对我来说,问题已通过创建新数据库并使用默认用户 postgres 并将 privileges 设置为如下图所示。

之前我从数据库中删除了 public User/Group 权限。