postgresql - How to disable embedded database Spring-boot spring-data-jpa -


i can't read/write on postgresql database (9.4) set locally. app use embedded database. when execute select queries on database, there no data inserted. check files please?

i'm using spring-boot spring-data-jpa.

file : application.properties

##database properties spring.datasource.driverclassname=org.postgresql.driver spring.datasource.url=jdbc:postgresql://localhost:5432/mydatabase spring.datasource.username=postgres spring.datasource.password=admin spring.data.jpa.repositories.enabled=true spring.jpa.show-sql=true spring.jpa.database-platform=org.hibernate.dialect.postgresqldialect spring.jpa.database=postgresql spring.jpa.hibernate.ddl-auto=create-drop 

file : 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>      <groupid>fr.mydomain</groupid>     <artifactid>myapp</artifactid>     <version>0.1.0</version>     <packaging>war</packaging>      <name>myapp</name>      <parent>         <groupid>org.springframework.boot</groupid>         <artifactid>spring-boot-starter-parent</artifactid>         <version>1.2.5.release</version>     </parent>      <dependencies>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-web</artifactid>         </dependency>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-thymeleaf</artifactid>         </dependency>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-tomcat</artifactid>             <scope>provided</scope>         </dependency>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-data-jpa</artifactid>         </dependency>         <dependency>             <groupid>org.postgresql</groupid>             <artifactid>postgresql</artifactid>             <version>9.4-1201-jdbc41</version>         </dependency>     </dependencies>      <properties>         <java.version>1.8</java.version>         <project.build.sourceencoding>utf-8</project.build.sourceencoding>     </properties>      <build>         <plugins>             <plugin>                 <groupid>org.springframework.boot</groupid>                 <artifactid>spring-boot-maven-plugin</artifactid>             </plugin>         </plugins>     </build>  </project> 

file : application.java

package fr.mydomain.myapp.config;  import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.boot.builder.springapplicationbuilder; import org.springframework.boot.context.web.springbootservletinitializer; import org.springframework.boot.orm.jpa.entityscan; import org.springframework.context.annotation.componentscan; import org.springframework.data.jpa.repository.config.enablejparepositories;  @springbootapplication @componentscan({ "fr.mydomain.myapp.*" }) @enablejparepositories(basepackages = "fr.mydomain.myapp.dao") @entityscan(basepackages = "fr.mydomain.myapp.model") public class application extends springbootservletinitializer {      public static void main(string[] args) {         springapplication.run(application.class, args);     }      @override     protected final springapplicationbuilder configure(final springapplicationbuilder application) {         return application.sources(application.class);     }  } 

file : customer.java

package fr.mydomain.myapp.model;  import java.io.serializable;  import javax.persistence.column; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.id;  @entity public class customer implements serializable {      private static final long serialversionuid = 1l;      @id     @generatedvalue(strategy = generationtype.auto)     /** id of customer */     private long customerid;      @column     /** lastname of customer */     private string lastname;      @column     /** firstname of customer */     private string firstname;      protected customer() {      }      public customer(string lastname, string firstname) {         this.lastname = lastname;         this.firstname = firstname;     }      public long getcustomerid() {         return customerid;     }      public void setcustomerid(long customerid) {         this.customerid = customerid;     }      public string getlastname() {         return lastname;     }      public void setlastname(string lastname) {         this.lastname = lastname;     }      public string getfirstname() {         return firstname;     }      public void setfirstname(string firstname) {         this.firstname = firstname;     }      @override     public string tostring() {         return string.format("customer[customerid= %d, lastname= '%s', firstname= '%s'", customerid, lastname,                 firstname);     } } 

file : customerrepository.java

package fr.mydomain.myapp.dao;  import java.util.list;  import org.springframework.data.repository.crudrepository;  import fr.ineatconseil.picombo.model.customer;  public interface customerrepository extends crudrepository<customer, long> {      list<customer> findcustomerdistinctbylastnameorfirstname(string lastname, string firstname);  } 

file : beaconcontroller.java

package fr.mydomain.myapp.controller;  import org.slf4j.logger; import org.slf4j.loggerfactory; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.modelattribute; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.responsebody;  import fr.mydomain.myapp.dao.customerrepository; import fr.mydomain.myapp.model.customer;  @controller public class beaconcontroller {      private final logger logger = loggerfactory.getlogger(this.getclass());      @autowired     customerrepository customerrepository;      @requestmapping(value = "/beacon", method = requestmethod.get)     public string index() {          customerrepository.save(new customer("jack", "bauer"));         customerrepository.save(new customer("johnny", "joe"));         customerrepository.save(new customer("bobby", "bob"));         customerrepository.save(new customer("jean", "bonbeurre"));         customerrepository.save(new customer("anna-lyse", "durine"));          // fetch customers         system.out.println("customers found findall():");         system.out.println("-------------------------------");         (customer customer : customerrepository.findall()) {             system.out.println(customer);         }         system.out.println();          customer customer = customerrepository.findone(2l);         system.out.println("customer found findone(2l):");         system.out.println("--------------------------------");         system.out.println(customer);         system.out.println();          // fetch customers lastname or firstname         system.out.println("customers found findcustomerdistinctbylastnameorfirstname():");         system.out.println("-------------------------------");         (customer customer2 : customerrepository.findcustomerdistinctbylastnameorfirstname("jack", "bob")) {             system.out.println(customer2);         }         system.out.println();          return "beacon";     } } 

i found solution weekend.

i had tables "customer" , "product" capital letters in database data , app created me tables "customer" , "product". so, didn't extract data

:/


Comments