Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.NoSuchMethodError:com.google.common.base.Platform.systemNanoTime()J_Java_Google Cloud Sql - Fatal编程技术网

java.lang.NoSuchMethodError:com.google.common.base.Platform.systemNanoTime()J

java.lang.NoSuchMethodError:com.google.common.base.Platform.systemNanoTime()J,java,google-cloud-sql,Java,Google Cloud Sql,我想连接到谷歌云Sql表单java到这个错误主程序,而运行我的代码时,我有这个错误 public static void main(String[] args) throws SQLNonTransientConnectionException, IOException, SQLException, ClassNotFoundException { String instanceConnectionName = "****"; String databas

我想连接到谷歌云Sql表单java到这个错误主程序,而运行我的代码时,我有这个错误

public static void main(String[] args) throws SQLNonTransientConnectionException,
            IOException, SQLException, ClassNotFoundException {
    String instanceConnectionName = "****";
    String databaseName = "***";
    String IP_of_instance = "***";
    String username = "***";
    String password = "****";
    String jdbcUrl = String.format(
            "jdbc:mysql://%s/%s?cloudSqlInstance=%s"
            + "&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false",
            IP_of_instance,
            databaseName,
            instanceConnectionName);

    Connection connection = DriverManager.getConnection(jdbcUrl, username, password);

    try (Statement statement = connection.createStatement()) {
        ResultSet resultSet = statement.executeQuery("SHOW TABLES");
        while (resultSet.next()) {
            System.out.println(resultSet.getString(1));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
我在运行代码时遇到此错误:

java.lang.NoSuchMethodError:com.google.common.base.Platform.systemNanoTimeJ

这是我的pom文件,我添加了依赖项,但仍然无法访问该类

 <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>1.9.69</version>
    </dependency>
    <dependency>
        <groupId>org.httprpc</groupId>
        <artifactId>httprpc</artifactId>
        <version>6.3.3</version>
    </dependency>
    <!-- [START servlet] -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>
    <!-- [END servlet] -->
    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client-appengine</artifactId>
        <version>1.7.0-beta</version>
    </dependency>
    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
        <version>3.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-urlshortener</artifactId>
        <version>v1-rev57-1.25.0</version>
    </dependency>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>
    <dependency>
        <groupId>com.healthmarketscience.sqlbuilder</groupId>
        <artifactId>sqlbuilder</artifactId>
        <version>3.0.0</version>
    </dependency>
    <!-- [START_EXCLUDE] -->
    <!-- Test Dependencies -->
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-testing</artifactId>
        <version>1.9.69</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.firebase</groupId>
        <artifactId>firebase-admin</artifactId>
        <version>6.8.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-stubs</artifactId>
        <version>1.9.69</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-tools-sdk</artifactId>
        <version>1.9.69</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client</artifactId>
        <version>1.30.2</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>23.5-jre</version>
    </dependency>
    <dependency>
        <groupId>com.google.truth</groupId>
        <artifactId>truth</artifactId>
        <version>0.42</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13-beta-1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>2.23.4</version>
        <scope>test</scope>
    </dependency>
    <dependency> <!-- Only used locally -->
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.42</version>
    </dependency>
    <dependency>
        <groupId>com.google.cloud.sql</groupId>
        <artifactId>mysql-socket-factory</artifactId>
        <version>1.0.12</version>
    </dependency>
    <!-- [END_EXCLUDE] -->
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20160810</version>
        <type>jar</type>
    </dependency>

验证是否在同一项目的Java构建路径中使用google-collect-1.0-rc1.jar和Java-18.0.jar。请删除google-collect

这是来源


这可能是由不同的番石榴版本引起的。如果这个错误发生在运行时,你能告诉我们你的代码是如何打包的吗?所以我要做什么来解决这个问题请建议我..你的代码是如何打包的?它是一个胖罐子吗?您的应用程序在运行时嵌入了哪个Guava版本?