0
votes

Problème déploier l'application de démarrage de printemps sur Heroku

J'ai une application de démarrage de printemps, avec une base de données. Pour tester, j'ai utilisé la base de données H2 et tout fonctionne bien. Maintenant, j'essaie de déployer mon application sur Heroku. Dans mon alimentation de mon activité, je reçois le message que la construction est réussie et que l'application a été déployée. Quand je vais à l'URL, j'obtiens une erreur d'application.

Je suppose qu'il y a un problème avec ma connexion à la base de données PostgreSQL. Au printemps, j'utilise le jParePository. P>

Ceci est mon application.Properties, ceci à partir de ma base de données H2, donc pas très utile maintenant: p> xxx pré>

sur Heroku, j'ai la configuration suivante Vars: P>

 héroku configs vars p>

Voir l'image: L'URL de la base de données a été remplie, le mot de passe est une copie de Les paramètres de la base de données sur Heroku, URL de la base de données Spring JDBC: PostgreSQL: Critiques de la base de données hôte: 5432 / Nom de la base de données et nom d'utilisateur est également une copie du nom d'utilisateur de la base de données p>

Ceci est mon fichier pom.xml: p >

2019-03-12T20:13:26.055651+00:00 app[web.1]: 
2019-03-12T20:13:26.055693+00:00 app[web.1]:   .   ____          _            __ _ _
2019-03-12T20:13:26.055748+00:00 app[web.1]:  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2019-03-12T20:13:26.055804+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2019-03-12T20:13:26.055873+00:00 app[web.1]:  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2019-03-12T20:13:26.055908+00:00 app[web.1]:   '  |____| .__|_| |_|_| |_\__, | / / / /
2019-03-12T20:13:26.055962+00:00 app[web.1]:  =========|_|==============|___/=/_/_/_/
2019-03-12T20:13:26.057441+00:00 app[web.1]:  :: Spring Boot ::        (v2.1.3.RELEASE)
2019-03-12T20:13:26.057564+00:00 app[web.1]: 
2019-03-12T20:13:26.448731+00:00 app[web.1]: 2019-03-12 20:13:26.428  INFO 4 --- [           main] info.climbinggyms.main.MainApplication   : Starting MainApplication v0.0.1-SNAPSHOT on 3853ed86-86c8-4fb2-8e13-6f34d48b748e with PID 4 (/app/target/main-0.0.1-SNAPSHOT.jar started by u45998 in /app)
2019-03-12T20:13:26.458624+00:00 app[web.1]: 2019-03-12 20:13:26.458  INFO 4 --- [           main] info.climbinggyms.main.MainApplication   : No active profile set, falling back to default profiles: default
2019-03-12T20:13:29.684952+00:00 app[web.1]: 2019-03-12 20:13:29.683  INFO 4 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-03-12T20:13:30.153545+00:00 app[web.1]: 2019-03-12 20:13:30.149  INFO 4 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 450ms. Found 4 repository interfaces.
2019-03-12T20:13:31.821390+00:00 app[web.1]: 2019-03-12 20:13:31.820  INFO 4 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$319e3998] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-12T20:13:33.320904+00:00 app[web.1]: 2019-03-12 20:13:33.320  INFO 4 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 21282 (http)
2019-03-12T20:13:33.430459+00:00 app[web.1]: 2019-03-12 20:13:33.430  INFO 4 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-03-12T20:13:33.430662+00:00 app[web.1]: 2019-03-12 20:13:33.430  INFO 4 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-03-12T20:13:33.446525+00:00 app[web.1]: 2019-03-12 20:13:33.446  INFO 4 --- [           main] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/app/.jdk/jre/lib/amd64/server::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2019-03-12T20:13:33.589450+00:00 app[web.1]: 2019-03-12 20:13:33.589  INFO 4 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-03-12T20:13:33.589765+00:00 app[web.1]: 2019-03-12 20:13:33.589  INFO 4 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 6086 ms
2019-03-12T20:13:34.018325+00:00 app[web.1]: 2019-03-12 20:13:34.017 ERROR 4 --- [           main] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.
2019-03-12T20:13:34.018337+00:00 app[web.1]: 
2019-03-12T20:13:34.018339+00:00 app[web.1]: 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.
2019-03-12T20:13:34.018340+00:00 app[web.1]:    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:280) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-03-12T20:13:34.018348+00:00 app[web.1]:    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-03-12T20:13:34.018350+00:00 app[web.1]:    at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-03-12T20:13:34.018352+00:00 app[web.1]:    at org.postgresql.Driver.makeConnection(Driver.java:454) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-03-12T20:13:34.018353+00:00 app[web.1]:    at org.postgresql.Driver.connect(Driver.java:256) ~[postgresql-42.2.5.jar!/:42.2.5]
2019-03-12T20:13:34.018354+00:00 app[web.1]:    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:319) ~[tomcat-jdbc-9.0.16.jar!/:na]
2019-03-12T20:13:34.018355+00:00 app[web.1]:    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:212) ~[tomcat-jdbc-9.0.16.jar!/:na]
2019-03-12T20:13:34.018357+00:00 app[web.1]:    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:739) [tomcat-jdbc-9.0.16.jar!/:na]
2019-03-12T20:13:34.018358+00:00 app[web.1]:    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:671) [tomcat-jdbc-9.0.16.jar!/:na]
2019-03-12T20:13:34.018359+00:00 app[web.1]:    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:483) [tomcat-jdbc-9.0.16.jar!/:na]
2019-03-12T20:13:34.018361+00:00 app[web.1]:    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154) [tomcat-jdbc-9.0.16.jar!/:na]
2019-03-12T20:13:34.018362+00:00 app[web.1]:    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-9.0.16.jar!/:na]
2019-03-12T20:13:34.018363+00:00 app[web.1]:    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-9.0.16.jar!/:na]
2019-03-12T20:13:34.018365+00:00 app[web.1]:    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) [tomcat-jdbc-9.0.16.jar!/:na]
2019-03-12T20:13:34.018371+00:00 app[web.1]:    at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:157) [spring-jdbc-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
2019-03-12T20:13:34.018372+00:00 app[web.1]:    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115) [spring-jdbc-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
2019-03-12T20:13:34.018374+00:00 app[web.1]:    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78) [spring-jdbc-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
2019-03-12T20:13:34.018375+00:00 app[web.1]:    at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319) [spring-jdbc-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
2019-03-12T20:13:34.018376+00:00 app[web.1]:    at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356) [spring-jdbc-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
2019-03-12T20:13:34.018378+00:00 app[web.1]:    at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:73) [spring-boot-autoconfigure-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
2019-03-12T20:13:34.018379+00:00 app[web.1]:    at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:142) [spring-boot-autoconfigure-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
2019-03-12T20:13:34.018381+00:00 app[web.1]:    at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:113) [spring-boot-autoconfigure-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]
2019-03-12T20:13:34.018383+00:00 app[web.1]:    at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$$5074fc07.CGLIB$jpaVendorAdapter$8(<generated>) [spring-boot-autoconfigure-2.1.3.RELEASE.jar!/:2.1.3.RELEASE]


1 commentaires

Bonjour Blâteau, il semble que vous essayiez de vous connecter à localhost: 5432 et vous obtenez une exception de connexion: org.postgresql.util.psqlexception . Pouvez-vous partager votre configuration de connexion?


3 Réponses :


0
votes

Selon le fichier journal que vous partagez, vous essayez de vous connecter à localhost: 5432 et vous recevez une exception org.postgresql.util.psqlexception . Selon votre image, la base de données Heroku devrait avoir un nom de domaine comme: EC2-54-247-85-251.EU-WEXXXXX .

Vous devez utiliser les variables d'environnement définies par Heroku, vous pouvez l'accumuler en modifiant les propriétés de votre application:

application.properties xxx

Veuillez vous reporter à heroku Documentation et référence pour Spring-boot .

update

Il semble que Pilote PostgreSQL ne prend pas en charge le format que vous avez sur votre URL de DataSource, vous devez suivre les formats suivants: xxx

donné que vous définissez printemps.datasource.Asername et spring.datasource.password .

ou xxx

Remarque: Vous pouvez obtenir un InvocationTargetExtion en raison de la création en tant que CreateClob () , c'est-à-dire une tentative d'hiberne de configuration d'une fonction postgreSQL ne s'applique pas, vous pouvez ignorer Exception.

Important: Réinitialisez vos informations d'identification afin que personne ne peut avoir accès à votre instance.


5 commentaires

J'ai ajouté ceci à mon apllication.properties et j'ai toujours le même problème. Toute la documentation ci-dessus est pour JDBC, j'utilise JPA, cela compte-t-il? Voici mes paramètres: SPRING_DATASOURCE_DRIVER-CLASSE NOM: org.postgresql.Driver SPRING_DATASOURCE_PASSWORD: pw copié à partir heroku paramètres db SPRING_DATASOURCE_TYPE: org.apache.tomcat.jdbc.pool.DataSource SPRING_DATASOURCE_URL: jdbc: postgresql: // sbrjqzkrjkkzmc: c23d70564aa42650ea2cd1f4532 1a1112096f86564a2b86 766BA36ADF8DFFA35 @ CE 2-54-247-85-251.EU-W Est-COMPUE.Amazon Aws.com:5432/DEDT2I3 DL1K7SM Spring_DataSource_USName: sbrjqzkrjkkzmc


Spring_JPA_Database-plate-forme: org.hibernate.dialect.postgresqldialect Spring_jpa_hibernate_ddl-Auto: Mise à jour et ceci est mon message de journalisation WebApplicationContext: Initialisation terminée en 2934 MS 2019-03-13T10: 13: 36.293244 + 00: 00 App [Web.1]: 2019 -03-13 10: 13: 36.292 ERROR 4 --- [MAIN] OATOMCAT.JDBC.POOL.ConnectionPOOL: Impossible de créer des connexions initiales de piscine. 2019-03-13T10: 13: 36.293258 + 00: 00 APP [Web.1]: 2019-03-13T10: 13: 36.293260 + 00: 00 App [Web.1]: org.postgresql.util.psqlexception: la connexion tentative a échoué.


Maintenant, vous rencontrez des problèmes avec une piscine de connexion, vous pouvez jeter un coup d'œil à ce tutoriel BAELDUNG .com / printemps-boot-tomcat-connexion-piscine


Il fonctionne enfin, j'ai supprimé toutes les configuration Vars dans Heroku, toutes les propriétés du printemps et ajouté uniquement le nom d'utilisateur, le mot de passe et l'URL dans le nouveau format et fonctionnent. Cette partie fonctionne, j'ai d'autres problèmes maintenant avec mon application, mais je vais essayer de les réparer moi-même. Merci beaucoup pour ton aide. Et je n'oublierai pas de changer mon mot de passe


Bienvenue, si cela ne vous dérange pas que vous puissiez marquer la réponse à droite, merci



1
votes

@cristian Je ne suis pas sûr, il semble toujours qu'il y a un problème avec la connexion à la base de données, c'est un extrait plus long de mon journal: xxx pré>

ceci est mon fichier pom.xml p> xxx pré>

Ceci est mon fichier de propriétés: p> xxx pré>

J'utilise l'interface JPA: P>

DATABASE_URL: postgres://sbrjqzkrjkkzmc:c23d70564aa42650ea2cd1f45321a1112096f86564a2b86766ba36adf8dffa35@ec2-54-247-85-251.eu-west-1.compute.amazonaws.com:5432/dedt2i3dl1k7sm
SPRING_DATASOURCE_DRIVER-CLASS-NAME: org.postgresql.Driver
SPRING_DATASOURCE_PASSWORD: c23d70564aa42650ea2cd1f45321a1112096f86564a2b86766ba36adf8dffa35
SPRING_DATASOURCE_TYPE: org.apache.tomcat.jdbc.pool.DataSource
SPRING_DATASOURCE_URL: jdbc:postgresql://sbrjqzkrjkkzmc:c23d70564aa42650ea2cd1f45321a1112096f86564a2b86766ba36adf8dffa35@ec2-54-247-85-251.eu-west-1.compute.amazonaws.com:5432/dedt2i3dl1k7sm
SPRING_DATASOURCE_USERNAME: sbrjqzkrjkkzmc
SPRING_JPA_DATABASE-PLATFORM: org.hibernate.dialect.PostgreSQLDialect
SPRING_JPA_HIBERNATE_DDL-AUTO: update


1 commentaires

Veuillez lire la mise à jour sur ma réponse, vous devrez peut-être mettre à jour le Spring_Datasource_url sur Heroku.



0
votes

Supprimer la propriété Java-Version dans POM.XML


1 commentaires

Bien que cela puisse être un indice précieux pour résoudre le problème, une bonne réponse démontre également la solution. S'il vous plaît Modifier pour fournir un code d'exemple pour montrer ce que vous voulez dire. Alternativement, envisagez d'écrire cela comme un commentaire à la place