我正在尝试创建一个宁静的应用程序通过以下你管视频,因为我是完全新的这一点。我无法创建表自动使用hibernate.ddl-auto = update
。我也尝试使用hibernate.ddl-auto = create
和spring.jpa.hibernate.hbm2ddl.auto = create
。我也必须改变服务器端口每一次运行应用程序。如何解决这些问题?
RestfulApplication1.java
package com.springboot.first.app;
import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import
数据源自动配置;
@SpringBootApplication
@EnableAutoConfiguration(exclude=
{DataSourceAutoConfiguration.class})
public class RestfulApplication1 {
public static void main(String[] args) {
SpringApplication.run(RestfulApplication1Application.class, args);
}
}
application.properties
spring.datasource.username=root
spring.datasource.password=**********
spring.datasource.url=jdbc:mysql://localhost:3306/emp?useSSL=false
jpa.属性。休眠方言= org.hibernate.dialect.MySQL5无源数据库方言
spring.datasource.driver.class-name=com.mysql.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=true
server.port = 6104
Employee.java
package com.springboot.first.app.model;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
@Data
@Entity
@Table(name="Employee")
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name = "first_name" , nullable = false)
private String firstName;
@Column(name = "last_name")
private String lastName;
@Column(name="email")
private String email;
}
控制台输出
1条答案
按热度按时间uemypmqf1#
使用此配置: