1

J'essaie de suivre le didacticiel suivant pour essayer d'exécuter l'application Spring Petclinic sur google app engine. Les actions décrites dans le tuorial sont en cours sur le shell nuage google:Erreur Google Cloud SQL: nom d'hôte inconnu

https://cloud.google.com/community/tutorials/run-spring-petclinic-on-app-engine-cloudsql

à l'étape 7:

./mvnw -Drun.profiles=mysql spring-boot:run 

mais je INTRODUISE l'erreur suivante

erreur Résumé (Cause):

Caused by: java.net.UnknownHostException: google: No address associated with hostname 
      at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_131] 
      at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[na:1.8.0_131] 
      at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[na:1.8.0_131] 
      at java.net.InetAddress.getAllByName0(InetAddress.java:1276) ~[na:1.8.0_131] 
      at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[na:1.8.0_131] 
      at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[na:1.8.0_131] 
      at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:188) ~[mysql-connector-java-5.1.42.jar:5.1.42] 
      at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300) ~[mysql-connector-java-5.1.42.jar:5.1.42] 
      ... 85 common frames omitted 

L'erreur complète peut être trouvée à:

https://pastebin.com/cuYzVmsa

Ci-dessous mon pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://maven.apache.org/POM/4.0.0" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>org.springframework.samples</groupId> 
    <artifactId>spring-petclinic</artifactId> 
    <version>1.5.1</version> 

    <parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.5.4.RELEASE</version> 
    </parent> 
    <name>petclinic</name> 

    <properties> 

    <!-- Generic properties --> 
    <java.version>1.8</java.version> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 

    <!-- Web dependencies --> 
    <webjars-bootstrap.version>3.3.6</webjars-bootstrap.version> 
    <webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version> 
    <webjars-jquery.version>2.2.4</webjars-jquery.version> 
    <wro4j.version>1.8.0</wro4j.version> 
    <thymeleaf.version>3.0.6.RELEASE</thymeleaf.version> 

    <cobertura.version>2.7</cobertura.version> 

    </properties> 

    <dependencies> 
    <!-- https://mvnrepository.com/artifact/com.google.cloud.sql/mysql-socket-factory --> 
<dependency> 
    <groupId>com.google.cloud.sql</groupId> 
    <artifactId>mysql-socket-factory</artifactId> 
    <version>1.0.3</version> 
</dependency> 

    <dependency> 
     <groupId>com.google.cloud.sql</groupId> 
     <artifactId>mysql-socket-factory-connector-j-6</artifactId> 
     <version>1.0.2</version> 
    </dependency> 
    <!-- Spring and Spring Boot dependencies --> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-actuator</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-cache</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-jpa</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-thymeleaf</artifactId> 
     <exclusions> 
     <exclusion> 
       <groupId>nz.net.ultraq.thymeleaf</groupId> 
       <artifactId>thymeleaf-layout-dialect</artifactId> 
     </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 

    <!-- Databases - Uses HSQL by default --> 
    <dependency> 
     <groupId>org.hsqldb</groupId> 
     <artifactId>hsqldb</artifactId> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <scope>runtime</scope> 
    </dependency> 

    <!-- caching --> 
    <dependency> 
     <groupId>javax.cache</groupId> 
     <artifactId>cache-api</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.ehcache</groupId> 
     <artifactId>ehcache</artifactId> 
    </dependency> 

    <!-- webjars --> 
    <dependency> 
     <groupId>org.webjars</groupId> 
     <artifactId>webjars-locator</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.webjars</groupId> 
     <artifactId>jquery</artifactId> 
     <version>${webjars-jquery.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.webjars</groupId> 
     <artifactId>jquery-ui</artifactId> 
     <version>${webjars-jquery-ui.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.webjars</groupId> 
     <artifactId>bootstrap</artifactId> 
     <version>${webjars-bootstrap.version}</version> 
    </dependency> 
    <!-- end of webjars --> 

    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-devtools</artifactId> 
     <scope>runtime</scope> 
    </dependency> 
    </dependencies> 

    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-maven-plugin</artifactId> 
     <executions> 
      <execution> 
      <!-- Spring Boot Actuator displays build-related information 
       if a META-INF/build-info.properties file is present --> 
      <goals> 
       <goal>build-info</goal> 
      </goals> 
      <configuration> 
       <additionalProperties> 
       <encoding.source>${project.build.sourceEncoding}</encoding.source> 
       <encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting> 
       <java.source>${maven.compiler.source}</java.source> 
       <java.target>${maven.compiler.target}</java.target> 
       </additionalProperties> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>cobertura-maven-plugin</artifactId> 
     <version>${cobertura.version}</version> 
     <configuration> 
      <check /> 
     </configuration> 
     <executions> 
      <execution> 
      <goals> 
       <goal>clean</goal> 
       <goal>check</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 

     <!-- Spring Boot Actuator displays build-related information if a git.properties 
     file is present at the classpath --> 
     <plugin> 
     <groupId>pl.project13.maven</groupId> 
     <artifactId>git-commit-id-plugin</artifactId> 
     <executions> 
      <execution> 
      <goals> 
       <goal>revision</goal> 
      </goals> 
      </execution> 
     </executions> 
     <configuration> 
      <verbose>true</verbose> 
      <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat> 
      <generateGitPropertiesFile>true</generateGitPropertiesFile> 
      <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties 
      </generateGitPropertiesFilename> 
      <failOnNoGitDirectory>false</failOnNoGitDirectory> 
     </configuration> 
     </plugin> 

     <plugin> 
     <groupId>ro.isdc.wro4j</groupId> 
     <artifactId>wro4j-maven-plugin</artifactId> 
     <version>${wro4j.version}</version> 
     <executions> 
      <execution> 
      <phase>generate-resources</phase> 
      <goals> 
       <goal>run</goal> 
      </goals> 
      </execution> 
     </executions> 
     <configuration> 
      <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory> 
      <cssDestinationFolder>${project.build.directory}/classes/static/resources/css</cssDestinationFolder> 
      <wroFile>${basedir}/src/main/wro/wro.xml</wroFile> 
      <extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile> 
      <contextFolder>${basedir}/src/main/less</contextFolder> 
     </configuration> 
     <dependencies> 
      <dependency> 
      <groupId>org.webjars</groupId> 
      <artifactId>bootstrap</artifactId> 
      <version>${webjars-bootstrap.version}</version> 
      </dependency> 
     </dependencies> 
     </plugin> 
    </plugins> 
    </build> 
    <reporting> 
    <plugins> 
     <!-- integrate maven-cobertura-plugin to project site --> 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>cobertura-maven-plugin</artifactId> 
     <version>${cobertura.version}</version> 
     <configuration> 
      <formats> 
      <format>html</format> 
      </formats> 
      <check /> 
     </configuration> 
     </plugin> 
    </plugins> 
    </reporting> 

</project> 

Toute aide est grandement appréciée

grâce

+0

avez-vous créé cette base de données? pouvez-vous y accéder via une méthode différente (peut-être le volet de gestion google sql)? A partir d'un post SO différent, je vois qu'une URL Google SQL ressemblerait plutôt à "jdbc: google: mysql: // festive-shark-90408: jour-joie-projet/base de données? User = joies" https: // stackoverflow. com/questions/29446212/i-cant-connecter-à-mon-google-cloud-SQL-base de données-de-ma-déployé-backend-servlet –

Répondre

0

que je rencontrais le EXACT même question. Heureusement, j'ai été capable de comprendre grâce à l'un des commentaires sur le fil du tutoriel.

Cette ligne à l'étape 5 du tutoriel est incorrect:

spring.datasource.url=jdbc:mysql://google/petclinic?cloudSqlInstance=INSTANCE_CONNECTION_NAME=com.google.cloud.sql.mysql.SocketFactory 

Au lieu de cela, vous devez avoir:

spring.datasource.url=jdbc:mysql://google/petclinic?cloudSqlInstance=INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.mysql.SocketFactory 

Il est vraiment regrettable. J'espère avoir aidé.