Merge branch 'master' into BAEL-16633

This commit is contained in:
Alessio Stalla
2019-10-30 23:09:06 +01:00
parent db85c8f275
commit 0e3e7e9106
20534 changed files with 1642680 additions and 0 deletions
@@ -0,0 +1,20 @@
package com.baeldung.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import javax.annotation.PostConstruct;
import java.util.TimeZone;
@SpringBootApplication
public class Application {
@PostConstruct
void started() {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@@ -0,0 +1,27 @@
package com.baeldung.boot;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class Controller {
@Autowired
UserRepository userRepository;
@GetMapping
public User get() {
User user = new User();
userRepository.save(user);
return user;
}
@GetMapping("/find")
public List<User> find() {
List<User> users = userRepository.findAll();
return users;
}
}
@@ -0,0 +1,40 @@
package com.baeldung.boot;
import org.springframework.data.annotation.CreatedDate;
import javax.persistence.*;
import java.util.Date;
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column
private String name;
@CreatedDate
private Date createdDate = new Date();
public Date getCreatedDate() {
return createdDate;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,10 @@
package com.baeldung.boot;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
@Repository
public interface UserRepository extends JpaRepository<User, Serializable> {
}
@@ -0,0 +1,14 @@
spring:
datasource:
url: jdbc:mysql://localhost:3306/test?useLegacyDatetimeCode=false
username: root
password:
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5Dialect
jdbc:
time_zone: UTC