2021-08-17

This commit is contained in:
2021-08-17 23:03:20 +09:00
parent 827351bdf5
commit a65d7f1fda
13 changed files with 232 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
/*
* Spring-boot Examples
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -0,0 +1,9 @@
package kr.pe.elex.examples;
import lombok.Data;
@Data
public class Copyright {
private int year = 2021;
private String holder = "Elex";
}

View File

@@ -0,0 +1,33 @@
/*
* Spring-boot Examples
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
@Slf4j
@Controller
public class MyController {
@Autowired
private MyService service;
@GetMapping({"/", "/persons"})
public String index(Model model) {
model.addAttribute("user", service.getUser());
model.addAttribute("copyright", service.getCopyright());
model.addAttribute("personList",service.getPersonList());
return "main";
}
}

View File

@@ -0,0 +1,26 @@
package kr.pe.elex.examples;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Slf4j
@Service
public class MyService {
public Person getUser() {
return new Person("Charlie", 14);
}
public List<Person> getPersonList() {
return Arrays.asList(
new Person("Charlie", 14),
new Person("Steve", 34),
new Person("Jane", 22));
}
public Copyright getCopyright() {
return new Copyright();
}
}

View File

@@ -0,0 +1,14 @@
package kr.pe.elex.examples;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class Person {
@JsonProperty
private String name;
@JsonProperty
private int age;
}

View File

@@ -0,0 +1,8 @@
/*
* Spring-boot Examples
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples;

View File

@@ -0,0 +1,5 @@
spring:
application:
name: My spring-boot project
server:
port: 8080

View File

@@ -0,0 +1,10 @@
('-. ('-. ) (`-.
_( OO) _( OO) ( OO ).
(,------.,--. (,------.(_/. \_)-.
| .---'| |.-') | .---' \ `.' /
| | | | OO ) | | \ /\
(| '--. | |`-' |(| '--. \ \ |
| .--'(| '---.' | .--' .' \_)
| `---.| | | `---. / .'. \
`------'`------' `------''--' '--'
powered by ELEX

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Spring-boot Examples
~
~ Copyright (c) 2021. Elex. All Rights Reserved.
~ https://www.elex-project.com/
-->
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
<springProperty name="LOG_DIR" source="logging.path"
defaultValue="${user.home}/logs"/>
<property name="LOG_PATH" value="${LOG_DIR}/stephanie.log"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<appender name="ROLLING-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>UTF-8</charset>
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<file>${LOG_PATH}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_DIR}/sebastian_%d{yyyy-MM-dd}_%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>60</maxHistory>
</rollingPolicy>
</appender>
<logger name="kr.pe.elex" level="debug" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ROLLING-FILE"/>
</logger>
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ROLLING-FILE"/>
</root>
</configuration>

View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="ko" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head">
<meta charset="UTF-8">
<title>Fragment</title>
</head>
<body>
<footer th:fragment="footer">
<p th:object="${copyright}">Copyright &copy; <span th:text="*{year}">2021</span>. <span th:text="*{holder}">ELEX</span>. All Rights Reserved.</p>
</footer>
</body>
</html>

View File

@@ -0,0 +1,17 @@
<!doctype html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragment :: head}"></head>
<body>
<p>
Hello, <span th:text="${user.name}">User Name</span>.
</p>
<ul th:each="person : ${personList}">
<li>
<a th:text="${person.name}"
th:attr="data-age=${person.age}"
th:href="@{/{name}(name=${person.name})}"></a>
</li>
</ul>
<footer th:include="~{fragment :: footer}"></footer>
</body>
</html>