java - spring boot data jpa mysql could not create database -


i new in spring post code, application.properties

spring.datasource.url=jdbc:mysql://localhost/spring spring.datasource.username=root spring.datasource.password= spring.datasource.driver-class-name=com.mysql.jdbc.driver spring.jpa.database-platform=org.hibernate.dialect.mysqldialect spring.jpa.hibernate.ddl-auto=update 

and entity

    package model;  import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.id;  @entity public class person {     @id       @generatedvalue(strategy = generationtype.auto) private long id; private string name; private string phone; private string adresse; public long getid() {     return id; } public void setid(long id) {     this.id = id; } public string getname() {     return name; } public void setname(string name) {     this.name = name; } public string getphone() {     return phone; } public void setphone(string phone) {     this.phone = phone; } public string getadresse() {     return adresse; } public void setadresse(string adresse) {     this.adresse = adresse; } public person(long id, string name, string phone, string adresse) {     super();     this.id = id;     this.name = name;     this.phone = phone;     this.adresse = adresse; } public person() {     super(); }  } 

and repository

package repositry;    import org.springframework.data.jpa.repository.jparepository;   import model.person;  public interface personrespositry extends  jparepository<person, long>  {   } 

and controller

   package contoller;  import java.util.list;  import org.springframework.beans.factory.annotation.autowired;  import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.restcontroller;  import model.person;  import repositry.personrespositry;  @restcontroller public class personcontroller {      personrespositry rp;     @autowired     public  personcontroller(personrespositry rp) {         // todo auto-generated constructor stub         this.rp=rp;     }       @requestmapping("/find")     public person find(long id){         return rp.findone(id);     }      @requestmapping("/findall")     public list<person> findall(){         return rp.findall();     }     @requestmapping(value="/hello")     public string demo(){         return "hello world !!";     }     @requestmapping(value="/create", method=requestmethod.get)     public string create(){         person p=new person();         p.setname("med");         p.setphone("233888");         p.setadresse("rue ");         rp.save(p);         return " success";     }   } 

this architect of project:

when run application database not generate , localhost:8080 running.

your problem location of application.java.

@componentscanlooks spring beans inside package of class annotated (@springbootapplication contains @componentscan) , in subpackages of package.

i provided example similar setup.

please have here: https://stackoverflow.com/a/27983870/2576531

furthermore hint of robert moskal correct. database has exist already. tables created automatically.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -