title: How to disable embedded database Spring-boot spring-data-jpa
body: <p>I can't Read/Write on my Postgresql database (9.4) set up locally. My app always use an embedded database. When I execute some select queries on my database, there is no data inserted. Could you check my files please? </p>
  
  <p>I'm using Spring-boot with Spring-Data-JPA.</p>
  
  <p>File : <strong>application.properties</strong></p>
  
  <pre><code>##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
  </code></pre>
  
  <p>File : <strong>pom.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;fr.mydomain&lt;/groupId&gt;
      &lt;artifactId&gt;MyApp&lt;/artifactId&gt;
      &lt;version&gt;0.1.0&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;MyApp&lt;/name&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.2.5.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
              &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
              &lt;version&gt;9.4-1201-jdbc41&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>File : <strong>Application.java</strong></p>
  
  <pre><code>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);
      }
  
  }
  </code></pre>
  
  <p>File : <strong>Customer.java</strong></p>
  
  <pre><code>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 the customer */
      private long customerID;
  
      @Column
      /** Lastname of the customer */
      private String lastname;
  
      @Column
      /** Firstname of the 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);
      }
  }
  </code></pre>
  
  <p>File : <strong>CustomerRepository.java</strong></p>
  
  <pre><code>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&lt;Customer, Long&gt; {
  
      List&lt;Customer&gt; findCustomerDistinctByLastnameOrFirstname(String lastname, String firstname);
  
  }
  </code></pre>
  
  <p>File : <strong>BeaconController.java</strong></p>
  
  <pre><code>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 all customers
          System.out.println("Customers found with findAll():");
          System.out.println("-------------------------------");
          for (Customer customer : customerRepository.findAll()) {
              System.out.println(customer);
          }
          System.out.println();
  
          Customer customer = customerRepository.findOne(2L);
          System.out.println("Customer found with findOne(2L):");
          System.out.println("--------------------------------");
          System.out.println(customer);
          System.out.println();
  
          // fetch all customers by lastname or firstname
          System.out.println("Customers found with findCustomerDistinctByLastnameOrFirstname():");
          System.out.println("-------------------------------");
          for (Customer customer2 : customerRepository.findCustomerDistinctByLastnameOrFirstname("Jack", "Bob")) {
              System.out.println(customer2);
          }
          System.out.println();
  
          return "beacon";
      }
  }
  </code></pre>