java – 驱动程序:org.postgresql.Driver@3ed03652为URL返回null …在部署春季启动时到Heroku
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – 驱动程序:org.postgresql.Driver@3ed03652为URL返回null …在部署春季启动时到Heroku,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4080字,纯文字阅读大概需要6分钟。
内容图文
我尝试在Heroku上部署我的应用程序,但有一些我无法解决的错误
我的application.poperties
spring.mvc.view.prefix = /WEB-INF/view/
spring.mvc.view.suffix = .jsp
spring.datasource.url = jdbc:postgres://user:pass@ec2-54-247-166-129.eu-west-1.compute.amazonaws.com:5432/database
# Username and password
spring.datasource.username = user
spring.datasource.password = pass
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
spring.datasource.driverClassName=org.postgresql.Driver
# ===============================
# = JPA / HIBERNATE
# ===============================
# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager).
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
我的Application类是用于应用程序启动的标准弹簧启动类
我的pom.xml(部分内容):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependencies>
<build>
<finalName>spring</finalName>
<plugins>
<!-- Spring Boot Maven -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.0.30.2</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我收到的错误
> 12:06:42.061 INFO 12352 --- [ost-startStop-1]
> o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:
> 'applicationContextIdFilter' to: [/*] 2017-03-10 12:06:42.488 ERROR
> 12352 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool :
> Unable to create initial connections of pool.
>
> java.sql.SQLException: Driver:org.postgresql.Driver@760cf594 returned
> null for
> URL:jdbc:postgres://fqwebtafwgsgmp:17ff02102b2660162ce1b053ef28340dfa7cf4d71e14b4bf1b187a8ad7d36579@ec2-54-247-166-129.eu-west-1.compute.amazonaws.com:5432/daapseha11ekml
> at
> org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:329)
> ~[tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203)
> ~[tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:732)
> [tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:664)
> [tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:479)
> [tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
> [tomcat-jdbc-8.5.11.jar:na] at
> org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118)
> [tomcat-jdbc-8.5.11.jar:na] at
如果有人解释我的错误,我将不胜感激
解决方法:
您在JDBC URL中使用jdbc:postgres而不是jdbc:postgresql(请注意额外的ql).
Heroku已经为您设置了SPRING_DATASOURCE_URL环境变量,因此您应该能够完全删除application.properties中的spring.datasource条目.
如果您无法删除它们,请尝试:
spring.datasource.url=${JDBC_DATABASE_URL}
如果这不起作用,它必须意味着您没有使用Java buildpack或其他东西.
还要确保运行:
heroku pg:credentials --reset
内容总结
以上是互联网集市为您收集整理的java – 驱动程序:org.postgresql.Driver@3ed03652为URL返回null …在部署春季启动时到Heroku全部内容,希望文章能够帮你解决java – 驱动程序:org.postgresql.Driver@3ed03652为URL返回null …在部署春季启动时到Heroku所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。