Initial version of spring demo1
This commit is contained in:
parent
4213a9edc6
commit
401b03a247
22 changed files with 645 additions and 67 deletions
|
@ -0,0 +1,13 @@
|
|||
package ch.polgrabia.demos.spring_demo1;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(SpringDemo1Application.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package ch.polgrabia.demos.spring_demo1;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringDemo1Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringDemo1Application.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package ch.polgrabia.demos.spring_demo1.controllers;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class TestController {
|
||||
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
||||
public ResponseEntity<TestResponse> handleInfo() {
|
||||
return ResponseEntity.ok(new TestResponse("ok"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package ch.polgrabia.demos.spring_demo1.controllers;
|
||||
|
||||
public record TestResponse(String response) {
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package ch.polgrabia.demos.spring_demo1.models;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
public class Person {
|
||||
@Id
|
||||
@Column
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "username")
|
||||
private String username;
|
||||
|
||||
@Column(name = "password")
|
||||
private String password;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
spring.application.name=spring_demo1
|
||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/app
|
||||
spring.datasource.username=postgres
|
||||
spring.datasource.password=secret
|
||||
spring.jpa.hibernate.ddl-auto=update
|
|
@ -0,0 +1,13 @@
|
|||
package ch.polgrabia.demos.spring_demo1;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SpringDemo1ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue