optimize imports, refformat code

This commit is contained in:
Marcin Michałek committed 2015-01-19 20:46:36 +01:00
1 parent bf6a536374
commit 3c3bbb8863
6 files changed
+20 -21

No files matched your search

+5 -7
View File
@@ -1,15 +1,12 @@
package hello;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import java.util.List;
@ComponentScan
@EnableAutoConfiguration
@@ -21,8 +18,9 @@ public class Application implements CommandLineRunner {
SpringApplication.run(Application.class, args);
}
@Override
public void run(String... args) throws Exception {
@Override
public void run(String... args) throws Exception {
// save a couple of customers
repository.save(new Customer("aJack", "Bauer"));
repository.save(new Customer("aChloe", "O'Brian"));
+6 -5
View File
@@ -7,14 +7,15 @@ import javax.persistence.*;
public class Customer {
@Id
@GeneratedValue(strategy=GenerationType.AUTO )
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column( name = "firstname")
@Column(name = "firstname")
private String firstName;
@Column( name = "lastname")
@Column(name = "lastname")
private String lastName;
protected Customer() {}
protected Customer() {
}
public Customer(String firstName, String lastName) {
this.firstName = firstName;
@@ -24,7 +25,7 @@ public class Customer {
public Customer(long id, String first_name, String last_name) {
this.firstName = first_name;
this.lastName = last_name;
this.id=id;
this.id = id;
}
public long getId() {
+2 -2
View File
@@ -14,11 +14,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
public class CustomerController {
@Autowired
CustomerRepository customerRepository;
CustomerRepository customerRepository;
@RequestMapping("/getAll")
@ResponseBody
Iterable<Customer> getAll(){
Iterable<Customer> getAll() {
return customerRepository.findAll();
}
}
+2 -2
View File
@@ -1,9 +1,9 @@
package hello;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
public interface CustomerRepository extends CrudRepository<Customer, Long> {
List<Customer> findByLastName(String lastName);
+1 -1
View File
@@ -37,7 +37,7 @@ public class JdbcTest {
System.out.println("Querying for customer records where first_name = 'Josh':");
List<Customer> results = jdbcTemplate.query(
"select * from customer where firstname = ?", new Object[] { "Josh" },
"select * from customer where firstname = ?", new Object[]{"Josh"},
new RowMapper<Customer>() {
@Override
public Customer mapRow(ResultSet rs, int rowNum) throws SQLException {
+4 -4
View File
@@ -1,4 +1,4 @@
spring.datasource.url=jdbc:postgresql://localhost:5432/wojnickitochuj
spring.datasource.username=lukasgol
spring.datasource.password=lukasgol
spring.datasource.driver-class-name=org.postgresql.Driver
#spring.datasource.url=jdbc:postgresql://localhost:5432/wojnickitochuj
#spring.datasource.username=lukasgol
#spring.datasource.password=lukasgol
#spring.datasource.driver-class-name=org.postgresql.Driver