mysql - 由于数据库访问凭据错误,Spring Boot War打包失败

标签 mysql maven spring-boot war

我正在尝试将我的 Spring Boot 应用程序部署到私有(private) JVM,该应用程序在我的本地设置上成功运行,我可以轻松构建 war ,在我的 application.properties 文件中,我有本地数据库的数据库连接属性,当我将它们更改为主机中数据库的凭据后,maven 构建失败并出现异常:

  Host 'X.X.X.X' is not allowed to connect to this MySQL server

我不明白为什么在构建过程中会尝试访问 mysql 服务器?

这是我的 pom.xml

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

<groupId>com.mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>myproject</name>
<description>description of my project</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.1.RELEASE</version>
    <relativePath/> 
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  <start-class>com.levels.website.LevelsApplication</start-class>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.6.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.mobile/spring-mobile-device -->
    <dependency>
        <groupId>org.springframework.mobile</groupId>
        <artifactId>spring-mobile-device</artifactId>
        <version>1.1.5.RELEASE</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

感谢任何帮助。

最佳答案

MySQL内部有一个表,定义了允许连接到服务器的主机。您需要在这些表中添加服务器的 IP。 How to allow remote connection to mysql

关于mysql - 由于数据库访问凭据错误,Spring Boot War打包失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42976986/

相关文章:

mysql - 使用 vb.net 不使用 picturebox 从 MySQL 检索 BLOB

java - 如何将 jar 依赖项项目中的资源包含在 war 文件中

java - 用于生产的外部容器中的 Spring Boot 嵌入式容器或 war 文件

java - Spring Boot中如何获取真实的uri地址?

spring - 在 Spring Data Neo4J 中保存关系的正确方法是什么?

java - Spring 安全登录404

PHP 和 MySQL 搜索大量列

javascript - 在复选框中显示来自 mySQL 的 true 或 false (0/1)

MYSQL查询出现语法错误

java - Maven错误: cannot find symbol class in a package