JAVA-19718 Minor corrections and fixes (#13865)
This commit is contained in:
parent
1137565f01
commit
db4e6d5e47
|
@ -2,19 +2,15 @@ package com.baeldung.dataloading;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.core.env.AbstractEnvironment;
|
import org.springframework.core.env.AbstractEnvironment;
|
||||||
|
|
||||||
import com.baeldung.boot.Application;
|
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackages = { "com.baeldung.dataloading" })
|
@SpringBootApplication(scanBasePackages = { "com.baeldung.dataloading" })
|
||||||
public class ApplicationDataLoading {
|
public class ApplicationDataLoading {
|
||||||
private static ApplicationContext applicationContext;
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "datasource");
|
System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "datasource");
|
||||||
|
|
||||||
applicationContext = SpringApplication.run(Application.class, args);
|
SpringApplication.run(ApplicationDataLoading.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.baeldung.dataloading.model;
|
||||||
|
|
||||||
|
import static javax.persistence.GenerationType.IDENTITY;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Country {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = IDENTITY)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,49 +0,0 @@
|
||||||
package com.baeldung.dataloading.model;
|
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "users")
|
|
||||||
public class User {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Integer id;
|
|
||||||
private String name;
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
public User() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public User(String name, Integer status) {
|
|
||||||
this.name = name;
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(Integer status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,10 +2,13 @@ spring.datasource.driver-class-name=org.h2.Driver
|
||||||
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
|
||||||
spring.datasource.username=sa
|
spring.datasource.username=sa
|
||||||
spring.datasource.password=
|
spring.datasource.password=
|
||||||
spring.jpa.hibernate.ddl-auto=none
|
|
||||||
|
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||||
|
spring.jpa.hibernate.ddl-auto=create
|
||||||
|
spring.jpa.defer-datasource-initialization=true
|
||||||
|
|
||||||
# Enabling H2 Console
|
# Enabling H2 Console
|
||||||
spring.h2.console.enabled=true
|
spring.h2.console.enabled=true
|
||||||
# Uppercase Table Names
|
|
||||||
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
|
# By default enabled for Embedded Databases
|
||||||
hibernate.globally_quoted_identifiers=true
|
#spring.sql.init.mode=always
|
||||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
|
Loading…
Reference in New Issue