我正在尝试使用spring boot创建war文件并部署在安装了postgres sql的远程安全linux vm上,我想使用服务从db获取数据(只读操作)。
我已为此编写代码并在application.properties下面使用:
spring.datasource.url=jdbc:postgresql://localhost/test ---localhost refers to the remote linux vm here
spring.datasource.username=test
spring.datasource.password=test
spring.jpa.generate-ddl=true
现在,当我进行maven安装来生成war文件时,我得到了以下异常:
2017-04-25 04:49:36.588 INFO 9184 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-04-25 04:49:38.084 ERROR 9184 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:262) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
可能,它试图连接到我的localhst获取postgres sql db的详细信息,但是我希望这个连接到远程linux vm,需要指针。