Move all samples to the root dir
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
This commit is contained in:
		
							parent
							
								
									0c6fcde001
								
							
						
					
					
						commit
						f1e4cca535
					
				
					 262 changed files with 0 additions and 0 deletions
				
			
		
							
								
								
									
										16
									
								
								spring-postgres/backend/src/main/java/com/company/project/Application.java
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										16
									
								
								spring-postgres/backend/src/main/java/com/company/project/Application.java
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,16 @@ | |||
| package com.company.project; | ||||
| 
 | ||||
| import org.springframework.boot.SpringApplication; | ||||
| import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||||
| import org.springframework.context.annotation.ComponentScan; | ||||
| 
 | ||||
| @SpringBootApplication | ||||
| @EnableAutoConfiguration | ||||
| @ComponentScan(basePackages = {"com.company.project"}) | ||||
| public class Application { | ||||
| 
 | ||||
|     public static void main(String[] args) { | ||||
|         SpringApplication.run(Application.class, args); | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,23 @@ | |||
| package com.company.project.controllers; | ||||
| 
 | ||||
| import com.company.project.entity.Greeting; | ||||
| import com.company.project.repository.GreetingRepository; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Controller; | ||||
| import org.springframework.ui.Model; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| 
 | ||||
| @Controller | ||||
| public class HomeController { | ||||
| 
 | ||||
|     @Autowired | ||||
|     private GreetingRepository repository; | ||||
| 
 | ||||
|     @GetMapping("/") | ||||
|     public String showHome(String name, Model model) { | ||||
|         Greeting dockerGreeting = repository.findById(1).orElse(new Greeting("Not Found 😕")); | ||||
|         model = model.addAttribute("name", dockerGreeting.getName()); | ||||
|         return "home"; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -0,0 +1,57 @@ | |||
| package com.company.project.entity; | ||||
| 
 | ||||
| import javax.persistence.Entity; | ||||
| import javax.persistence.Id; | ||||
| import javax.persistence.Table; | ||||
| 
 | ||||
| @Entity | ||||
| @Table(name = "GREETINGS") | ||||
| public class Greeting { | ||||
| 
 | ||||
|     @Id | ||||
|     private int id; | ||||
|     private String name; | ||||
| 
 | ||||
|     public Greeting() { | ||||
|     } | ||||
| 
 | ||||
|     public Greeting(String name) { | ||||
|         this.name = name; | ||||
|     } | ||||
| 
 | ||||
|     public Greeting(int id, String name) { | ||||
|         this.id = id; | ||||
|         this.name = name; | ||||
|     } | ||||
| 
 | ||||
|     public int getId() { | ||||
|         return id; | ||||
|     } | ||||
| 
 | ||||
|     public void setId(int id) { | ||||
|         this.id = id; | ||||
|     } | ||||
| 
 | ||||
|     public String getName() { | ||||
|         return name; | ||||
|     } | ||||
| 
 | ||||
|     public void setName(String name) { | ||||
|         this.name = name; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean equals(Object o) { | ||||
|         if (this == o) return true; | ||||
|         if (o == null || getClass() != o.getClass()) return false; | ||||
| 
 | ||||
|         Greeting greeting = (Greeting) o; | ||||
| 
 | ||||
|         return name.equals(greeting.name); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public int hashCode() { | ||||
|         return name.hashCode(); | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,9 @@ | |||
| package com.company.project.repository; | ||||
| 
 | ||||
| import com.company.project.entity.Greeting; | ||||
| import org.springframework.data.repository.CrudRepository; | ||||
| import org.springframework.stereotype.Repository; | ||||
| 
 | ||||
| @Repository | ||||
| public interface GreetingRepository extends CrudRepository<Greeting, Integer> { | ||||
| } | ||||
							
								
								
									
										11
									
								
								spring-postgres/backend/src/main/resources/application.properties
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										11
									
								
								spring-postgres/backend/src/main/resources/application.properties
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,11 @@ | |||
| spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect | ||||
| spring.jpa.hibernate.ddl-auto=none | ||||
| spring.jpa.hibernate.show-sql=true | ||||
| 
 | ||||
| spring.datasource.url=jdbc:postgresql://db:5432/${POSTGRES_DB} | ||||
| spring.datasource.username=postgres | ||||
| spring.datasource.password=${POSTGRES_PASSWORD:db-wrz2z} | ||||
| spring.datasource.initialization-mode=always | ||||
| spring.datasource.initialize=true | ||||
| spring.datasource.schema=classpath:/schema.sql | ||||
| spring.datasource.continue-on-error=true | ||||
							
								
								
									
										1
									
								
								spring-postgres/backend/src/main/resources/data.sql
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								spring-postgres/backend/src/main/resources/data.sql
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| INSERT INTO GREETINGS(name) values ('Docker'); | ||||
							
								
								
									
										4
									
								
								spring-postgres/backend/src/main/resources/schema.sql
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								spring-postgres/backend/src/main/resources/schema.sql
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | |||
| CREATE TABLE IF NOT EXISTS GREETINGS ( | ||||
|     id serial PRIMARY KEY, | ||||
|     name varchar(50) NOT NULL | ||||
| ); | ||||
							
								
								
									
										9
									
								
								spring-postgres/backend/src/main/resources/templates/home.ftlh
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								spring-postgres/backend/src/main/resources/templates/home.ftlh
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,9 @@ | |||
| <!DOCTYPE HTML> | ||||
| <html> | ||||
| <head> | ||||
|   <title>Getting Started: Serving Web Content</title> | ||||
|   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||||
| </head> | ||||
| <body> | ||||
| 	<p>Hello from ${name}!</p> | ||||
| </body> | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue