Spring boot doesn't generate the table schema
I am new to spring. When I launch application, it start very well, but it doesn't generate the table schemas. I do not know if I made a mistake or if there is a configuration to do
SpringBootApplication
package org.opendevup;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TpSpringMvcApplication {
public static void main(String args) {
SpringApplication.run(TpSpringMvcApplication.class, args);
}
}
application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/db_sco_mvc
spring.datasource.username=******
spring.datasource.password=******
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
server.port = 3647
Entity
package org.opendevup.entities;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
public class Etudiant implements Serializable{
@Id
@GeneratedValue
private Long id;
private String nom;
private Date dateNaissance;
private String email;
private String photo;
public Etudiant() {
super();
// TODO Auto-generated constructor stub
}
public Etudiant(String nom, Date dateNaissance, String email, String photo) {
super();
this.nom = nom;
this.dateNaissance = dateNaissance;
this.email = email;
this.photo = photo;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public Date getDateNaissance() {
return dateNaissance;
}
public void setDateNaissance(Date dateNaissance) {
this.dateNaissance = dateNaissance;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
}
Note: I have changed port of Tomcat because port 8080 is used by another process, and I have already created database : db_sco_mvc.
I am using maven for dependencies.
Best regards.
spring hibernate jpa
add a comment |
I am new to spring. When I launch application, it start very well, but it doesn't generate the table schemas. I do not know if I made a mistake or if there is a configuration to do
SpringBootApplication
package org.opendevup;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TpSpringMvcApplication {
public static void main(String args) {
SpringApplication.run(TpSpringMvcApplication.class, args);
}
}
application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/db_sco_mvc
spring.datasource.username=******
spring.datasource.password=******
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
server.port = 3647
Entity
package org.opendevup.entities;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
public class Etudiant implements Serializable{
@Id
@GeneratedValue
private Long id;
private String nom;
private Date dateNaissance;
private String email;
private String photo;
public Etudiant() {
super();
// TODO Auto-generated constructor stub
}
public Etudiant(String nom, Date dateNaissance, String email, String photo) {
super();
this.nom = nom;
this.dateNaissance = dateNaissance;
this.email = email;
this.photo = photo;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public Date getDateNaissance() {
return dateNaissance;
}
public void setDateNaissance(Date dateNaissance) {
this.dateNaissance = dateNaissance;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
}
Note: I have changed port of Tomcat because port 8080 is used by another process, and I have already created database : db_sco_mvc.
I am using maven for dependencies.
Best regards.
spring hibernate jpa
add a comment |
I am new to spring. When I launch application, it start very well, but it doesn't generate the table schemas. I do not know if I made a mistake or if there is a configuration to do
SpringBootApplication
package org.opendevup;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TpSpringMvcApplication {
public static void main(String args) {
SpringApplication.run(TpSpringMvcApplication.class, args);
}
}
application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/db_sco_mvc
spring.datasource.username=******
spring.datasource.password=******
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
server.port = 3647
Entity
package org.opendevup.entities;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
public class Etudiant implements Serializable{
@Id
@GeneratedValue
private Long id;
private String nom;
private Date dateNaissance;
private String email;
private String photo;
public Etudiant() {
super();
// TODO Auto-generated constructor stub
}
public Etudiant(String nom, Date dateNaissance, String email, String photo) {
super();
this.nom = nom;
this.dateNaissance = dateNaissance;
this.email = email;
this.photo = photo;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public Date getDateNaissance() {
return dateNaissance;
}
public void setDateNaissance(Date dateNaissance) {
this.dateNaissance = dateNaissance;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
}
Note: I have changed port of Tomcat because port 8080 is used by another process, and I have already created database : db_sco_mvc.
I am using maven for dependencies.
Best regards.
spring hibernate jpa
I am new to spring. When I launch application, it start very well, but it doesn't generate the table schemas. I do not know if I made a mistake or if there is a configuration to do
SpringBootApplication
package org.opendevup;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TpSpringMvcApplication {
public static void main(String args) {
SpringApplication.run(TpSpringMvcApplication.class, args);
}
}
application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/db_sco_mvc
spring.datasource.username=******
spring.datasource.password=******
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
server.port = 3647
Entity
package org.opendevup.entities;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
public class Etudiant implements Serializable{
@Id
@GeneratedValue
private Long id;
private String nom;
private Date dateNaissance;
private String email;
private String photo;
public Etudiant() {
super();
// TODO Auto-generated constructor stub
}
public Etudiant(String nom, Date dateNaissance, String email, String photo) {
super();
this.nom = nom;
this.dateNaissance = dateNaissance;
this.email = email;
this.photo = photo;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public Date getDateNaissance() {
return dateNaissance;
}
public void setDateNaissance(Date dateNaissance) {
this.dateNaissance = dateNaissance;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
}
Note: I have changed port of Tomcat because port 8080 is used by another process, and I have already created database : db_sco_mvc.
I am using maven for dependencies.
Best regards.
spring hibernate jpa
spring hibernate jpa
edited Nov 22 '18 at 16:31
Petar
588
588
asked Nov 22 '18 at 11:18
majohncmajohnc
31
31
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
In order to create a table and a schema, do the following:
Add @Entity, implement the Serializable interface and create default and all-arguments constructor for you entity object.
In application.properties, use this config:
# Mysql
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://myurl/myschema?createDatabaseIfNotExist=true
spring.datasource.username=user
spring.datasource.password=pass
# Hibernate
spring.datasource.platform=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.data.jpa.repositories.enabled=true
thanks for your reply but i have same issue,it's didn't generate shema
– majohnc
Nov 22 '18 at 13:40
Have you deleted the previously generated schema/database?
– Urosh T.
Nov 22 '18 at 13:50
Yee i did delete
– majohnc
Nov 22 '18 at 15:07
I note that @Entity is depreciated
– majohnc
Nov 22 '18 at 15:53
Which@Entityare you using? You should usejavax.persistence.Entity
– Urosh T.
Nov 22 '18 at 15:56
add a comment |
Also add below config in you application:
spring.jpa.generate-ddl=true
for ddl-auto, you can keep using update or try the create-drop
spring.jpa.hibernate.ddl-auto = create-drop
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429802%2fspring-boot-doesnt-generate-the-table-schema%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In order to create a table and a schema, do the following:
Add @Entity, implement the Serializable interface and create default and all-arguments constructor for you entity object.
In application.properties, use this config:
# Mysql
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://myurl/myschema?createDatabaseIfNotExist=true
spring.datasource.username=user
spring.datasource.password=pass
# Hibernate
spring.datasource.platform=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.data.jpa.repositories.enabled=true
thanks for your reply but i have same issue,it's didn't generate shema
– majohnc
Nov 22 '18 at 13:40
Have you deleted the previously generated schema/database?
– Urosh T.
Nov 22 '18 at 13:50
Yee i did delete
– majohnc
Nov 22 '18 at 15:07
I note that @Entity is depreciated
– majohnc
Nov 22 '18 at 15:53
Which@Entityare you using? You should usejavax.persistence.Entity
– Urosh T.
Nov 22 '18 at 15:56
add a comment |
In order to create a table and a schema, do the following:
Add @Entity, implement the Serializable interface and create default and all-arguments constructor for you entity object.
In application.properties, use this config:
# Mysql
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://myurl/myschema?createDatabaseIfNotExist=true
spring.datasource.username=user
spring.datasource.password=pass
# Hibernate
spring.datasource.platform=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.data.jpa.repositories.enabled=true
thanks for your reply but i have same issue,it's didn't generate shema
– majohnc
Nov 22 '18 at 13:40
Have you deleted the previously generated schema/database?
– Urosh T.
Nov 22 '18 at 13:50
Yee i did delete
– majohnc
Nov 22 '18 at 15:07
I note that @Entity is depreciated
– majohnc
Nov 22 '18 at 15:53
Which@Entityare you using? You should usejavax.persistence.Entity
– Urosh T.
Nov 22 '18 at 15:56
add a comment |
In order to create a table and a schema, do the following:
Add @Entity, implement the Serializable interface and create default and all-arguments constructor for you entity object.
In application.properties, use this config:
# Mysql
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://myurl/myschema?createDatabaseIfNotExist=true
spring.datasource.username=user
spring.datasource.password=pass
# Hibernate
spring.datasource.platform=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.data.jpa.repositories.enabled=true
In order to create a table and a schema, do the following:
Add @Entity, implement the Serializable interface and create default and all-arguments constructor for you entity object.
In application.properties, use this config:
# Mysql
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://myurl/myschema?createDatabaseIfNotExist=true
spring.datasource.username=user
spring.datasource.password=pass
# Hibernate
spring.datasource.platform=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.data.jpa.repositories.enabled=true
answered Nov 22 '18 at 11:37
Urosh T.Urosh T.
65711116
65711116
thanks for your reply but i have same issue,it's didn't generate shema
– majohnc
Nov 22 '18 at 13:40
Have you deleted the previously generated schema/database?
– Urosh T.
Nov 22 '18 at 13:50
Yee i did delete
– majohnc
Nov 22 '18 at 15:07
I note that @Entity is depreciated
– majohnc
Nov 22 '18 at 15:53
Which@Entityare you using? You should usejavax.persistence.Entity
– Urosh T.
Nov 22 '18 at 15:56
add a comment |
thanks for your reply but i have same issue,it's didn't generate shema
– majohnc
Nov 22 '18 at 13:40
Have you deleted the previously generated schema/database?
– Urosh T.
Nov 22 '18 at 13:50
Yee i did delete
– majohnc
Nov 22 '18 at 15:07
I note that @Entity is depreciated
– majohnc
Nov 22 '18 at 15:53
Which@Entityare you using? You should usejavax.persistence.Entity
– Urosh T.
Nov 22 '18 at 15:56
thanks for your reply but i have same issue,it's didn't generate shema
– majohnc
Nov 22 '18 at 13:40
thanks for your reply but i have same issue,it's didn't generate shema
– majohnc
Nov 22 '18 at 13:40
Have you deleted the previously generated schema/database?
– Urosh T.
Nov 22 '18 at 13:50
Have you deleted the previously generated schema/database?
– Urosh T.
Nov 22 '18 at 13:50
Yee i did delete
– majohnc
Nov 22 '18 at 15:07
Yee i did delete
– majohnc
Nov 22 '18 at 15:07
I note that @Entity is depreciated
– majohnc
Nov 22 '18 at 15:53
I note that @Entity is depreciated
– majohnc
Nov 22 '18 at 15:53
Which
@Entity are you using? You should use javax.persistence.Entity– Urosh T.
Nov 22 '18 at 15:56
Which
@Entity are you using? You should use javax.persistence.Entity– Urosh T.
Nov 22 '18 at 15:56
add a comment |
Also add below config in you application:
spring.jpa.generate-ddl=true
for ddl-auto, you can keep using update or try the create-drop
spring.jpa.hibernate.ddl-auto = create-drop
add a comment |
Also add below config in you application:
spring.jpa.generate-ddl=true
for ddl-auto, you can keep using update or try the create-drop
spring.jpa.hibernate.ddl-auto = create-drop
add a comment |
Also add below config in you application:
spring.jpa.generate-ddl=true
for ddl-auto, you can keep using update or try the create-drop
spring.jpa.hibernate.ddl-auto = create-drop
Also add below config in you application:
spring.jpa.generate-ddl=true
for ddl-auto, you can keep using update or try the create-drop
spring.jpa.hibernate.ddl-auto = create-drop
answered Nov 23 '18 at 12:44
AlokAlok
235
235
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429802%2fspring-boot-doesnt-generate-the-table-schema%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown