【问题标题】:Not able to connect Mysql with Spring tool suite?无法将 Mysql 与 Spring 工具套件连接?
【发布时间】:2019-10-07 18:16:40
【问题描述】:

tomcat端口和mysql端口应该一样吗? 我想通过 rest-apis 访问 mysql 数据库。我无法同时打开 mysql 工作台和运行 spring boot。是因为两者都使用相同的端口吗?此外,如果我在 application.properties 中更改端口 - “server.port=7070”- 项目不会成功运行。

application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/playjava?useSSL=flase
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
server.port=3306

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>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>RestWithJPACreateProfessor</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>RestWithJPACreateProfessor</name>
<description>Demo project for Spring Boot</description>

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</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>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

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

请帮忙。提前谢谢你。

【问题讨论】:

  • 你在 spring.datasource.url=jdbc:mysql://localhost:3306/playjava?useSSL=flase (flase 而不是 false) 中有错字不知道是不是你的问题跨度>
  • 服务器端口和mysql端口确实不一样。

标签: java mysql rest spring-boot dependencies


【解决方案1】:

我不得不卸载并重新安装 spring 工具套件和 mysql。此外,我必须卸载在我的计算机上(独立)运行的 tomcat,因为我无法使用端口 8080。这就是为什么我将端口 3306 用于 spring 项目以及 mysql 的原因。因此,我无法在项目运行时同时打开 mysql。

【讨论】:

    猜你喜欢
    • 2015-06-06
    • 2021-10-23
    • 2022-06-16
    • 2013-02-22
    • 1970-01-01
    • 2021-06-06
    • 1970-01-01
    • 2019-12-03
    • 1970-01-01
    相关资源
    最近更新 更多