findByEmail(String email);
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/view/RootController.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.view;
2 |
3 | import org.springframework.web.bind.annotation.GetMapping;
4 |
5 | import io.honeymon.boot.springboot.view.annotation.ViewController;
6 |
7 | @ViewController
8 | public class RootController {
9 |
10 | @GetMapping("/root")
11 | public String root() {
12 | return "root";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/resources/templates/view-error.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 | Boot Spring Boot Error
7 |
8 |
9 | Occurred Exception
10 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/client/HoneymonApiRestClient.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.client;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import org.springframework.web.client.RestTemplate;
5 |
6 | @RequiredArgsConstructor
7 | public class HoneymonApiRestClient implements HoneymonApiClient {
8 | private final HoneymonApiProperties properties;
9 | private final RestTemplate restTemplate;
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/api/GreetingController.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.api;
2 |
3 | import org.springframework.web.bind.annotation.GetMapping;
4 | import org.springframework.web.bind.annotation.RestController;
5 |
6 | @RestController
7 | public class GreetingController {
8 |
9 | @GetMapping("/greeting")
10 | public String greeting() {
11 | return "Hello, Boot Spring Boot!!";
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/view/ErrorViewController.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.view;
2 |
3 | import org.springframework.web.bind.annotation.GetMapping;
4 |
5 | import io.honeymon.boot.springboot.view.annotation.ViewController;
6 |
7 | @ViewController
8 | public class ErrorViewController {
9 |
10 | @GetMapping("/occurred-error")
11 | public String occurError() {
12 | throw new RuntimeException("에러야 일어나라!!!");
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/runner/CmdRunner.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.runner;
2 |
3 | import org.springframework.boot.CommandLineRunner;
4 | import org.springframework.stereotype.Component;
5 |
6 | import lombok.extern.slf4j.Slf4j;
7 |
8 | @Slf4j
9 | @Component
10 | public class CmdRunner implements CommandLineRunner {
11 | @Override
12 | public void run(String... args) throws Exception {
13 | log.debug("Run CmdRunner.");
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/java/io/honeymon/boot/springboot/BootSpringBootApplicationTests.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | /**
7 | * Spring Boot 2.4.0 부터 junit-vintage-engine 이 제거되었다.
8 | * Spring Boot 2.4.0 으로 업그레이드 하려면 JUnit5 로 이관을 마쳐야 한다.
9 | */
10 | @SpringBootTest
11 | public class BootSpringBootApplicationTests {
12 |
13 | @Test
14 | public void contextLoads() {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/AvoidDefaultPackagePosition.java:
--------------------------------------------------------------------------------
1 | import org.springframework.boot.autoconfigure.SpringBootApplication;
2 |
3 | /**
4 | * 이 위치에 생성하는 것은 피하자!!
5 | * SpringBootApplication 이 선언되어 있는 메인클래스의 위치에 따라 관련된 컴포넌트를 탐색하는데 사용된다.
6 | *
7 | * @author honeymon
8 | *
9 | * Using
11 | * the “default” package
12 | */
13 | public class AvoidDefaultPackagePosition {
14 | }
15 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/runner/AppRunner.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.runner;
2 |
3 | import org.springframework.boot.ApplicationArguments;
4 | import org.springframework.boot.ApplicationRunner;
5 | import org.springframework.stereotype.Component;
6 |
7 | import lombok.extern.slf4j.Slf4j;
8 |
9 |
10 | @Slf4j
11 | @Component
12 | public class AppRunner implements ApplicationRunner {
13 | @Override
14 | public void run(ApplicationArguments args) throws Exception {
15 | log.debug("Run AppRunner.");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/service/MyJdbcTemplateBean.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.jdbc.core.JdbcTemplate;
5 | import org.springframework.stereotype.Component;
6 |
7 | @Component
8 | public class MyJdbcTemplateBean {
9 | private final JdbcTemplate jdbcTemplate;
10 |
11 | @Autowired
12 | public MyJdbcTemplateBean(JdbcTemplate jdbcTemplate) {
13 | this.jdbcTemplate = jdbcTemplate;
14 | }
15 |
16 | // 구현사항
17 | }
--------------------------------------------------------------------------------
/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | ___ __ ____ _ ___ __
2 | / _ )___ ___ / /_ / __/__ ____(_)__ ___ _ / _ )___ ___ / /_
3 | / _ / _ \/ _ \/ __/ _\ \/ _ \/ __/ / _ \/ _ `/ / _ / _ \/ _ \/ __/
4 | /____/\___/\___/\__/ /___/ .__/_/ /_/_//_/\_, / /____/\___/\___/\__/
5 | /_/ /___/
6 |
7 | * Github Repository: https://github.com/ihoneymon/boot-spring-boot
8 | * Application: ${application.title}${application.formatted-version}, Spring Boot Version:${spring-boot.formatted-version}
9 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/service/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.service;
2 |
3 | import java.util.Optional;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 |
8 | import io.honeymon.boot.springboot.domain.User;
9 | import io.honeymon.boot.springboot.domain.UserRepository;
10 |
11 | @Service
12 | public class UserServiceImpl implements UserService {
13 |
14 | @Autowired
15 | UserRepository repository;
16 |
17 | @Override
18 | public Optional findById(Long id) {
19 | return repository.findById(id);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/webcomponent/AttrListener.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.webcomponent;
2 |
3 | import javax.servlet.ServletContextEvent;
4 | import javax.servlet.ServletContextListener;
5 | import javax.servlet.annotation.WebListener;
6 |
7 | @WebListener
8 | public class AttrListener implements ServletContextListener {
9 |
10 | @Override
11 | public void contextInitialized(ServletContextEvent sce) {
12 | sce.getServletContext().setAttribute("servlet-context-attr", "honeymon");
13 | }
14 |
15 | @Override
16 | public void contextDestroyed(ServletContextEvent sce) {
17 | // TODO Auto-generated method stub
18 |
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/listener/ApplicationReadyEventListener.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.listener;
2 |
3 | import org.springframework.boot.context.event.ApplicationReadyEvent;
4 | import org.springframework.context.ApplicationListener;
5 |
6 | import lombok.extern.slf4j.Slf4j;
7 |
8 | /**
9 | * Application 의 준비가 완료되었을 때 발생하는 이벤트 리스너
10 | *
11 | * @author honeymon
12 | *
13 | */
14 | @Slf4j
15 | public class ApplicationReadyEventListener implements ApplicationListener {
16 |
17 | @Override
18 | public void onApplicationEvent(ApplicationReadyEvent event) {
19 | log.info("Application ready: {}", event);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/listener/ApplicationStartingEventListener.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.listener;
2 |
3 | import org.springframework.boot.context.event.ApplicationStartingEvent;
4 | import org.springframework.context.ApplicationListener;
5 |
6 | import lombok.extern.slf4j.Slf4j;
7 |
8 | /**
9 | * Application 이 구동되는 순간 발생하는 리스너
10 | *
11 | * @author honeymon
12 | *
13 | */
14 | @Slf4j
15 | public class ApplicationStartingEventListener implements ApplicationListener {
16 | @Override
17 | public void onApplicationEvent(ApplicationStartingEvent event) {
18 | log.info("Application Start: {}", event);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/webcomponent/HelloServlet.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.webcomponent;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.servlet.ServletException;
6 | import javax.servlet.annotation.WebServlet;
7 | import javax.servlet.http.HttpServlet;
8 | import javax.servlet.http.HttpServletRequest;
9 | import javax.servlet.http.HttpServletResponse;
10 |
11 | @WebServlet("/hello")
12 | public class HelloServlet extends HttpServlet {
13 |
14 | @Override
15 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
16 | try {
17 | resp.getOutputStream().write("hello".getBytes());
18 | } catch (Exception e) {
19 | e.printStackTrace();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/service/BootService.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.service;
2 |
3 |
4 | import javax.annotation.PostConstruct;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 | import io.honeymon.boot.springboot.config.ExampleProperties;
10 | import lombok.extern.slf4j.Slf4j;
11 |
12 | @Slf4j
13 | @Service
14 | public class BootService {
15 |
16 | private ExampleProperties properties;
17 |
18 | @Autowired
19 | public BootService(ExampleProperties properties) {
20 | this.properties = properties;
21 | }
22 |
23 | @PostConstruct
24 | public void init() {
25 | log.debug("Injected properties: {}", this.properties);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/.idea/modules/boot-spring-boot.test.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/java/io/honeymon/boot/springboot/domain/UserRepositoryTest.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.domain;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 |
7 | import static org.assertj.core.api.Assertions.assertThat;
8 |
9 | @SpringBootTest
10 | public class UserRepositoryTest {
11 |
12 | @Autowired
13 | UserRepository repository;
14 |
15 | @Test
16 | public void add() throws Exception {
17 | // given
18 | User user = new User("ihoneymon+test@gmail.com", "password");
19 |
20 | // when
21 | repository.save(user);
22 |
23 | // then
24 | assertThat(user.getId()).isNotNull();
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/support/AppArgsAccessor.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.support;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.boot.ApplicationArguments;
7 | import org.springframework.stereotype.Component;
8 |
9 | import lombok.extern.slf4j.Slf4j;
10 |
11 | @Slf4j
12 | @Component
13 | public class AppArgsAccessor {
14 |
15 | @Autowired
16 | public AppArgsAccessor(ApplicationArguments args) {
17 | boolean debug = args.containsOption("debug");
18 | log.debug("debug={}", debug);
19 |
20 | List files = args.getNonOptionArgs();
21 | log.debug("files={}", files);
22 |
23 | // if run with "--debug logfile.txt" debug=true, files=["logfile.txt"]
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/config/WebMvcConfig.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.config;
2 |
3 | import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.data.web.config.EnableSpringDataWebSupport;
7 | import org.springframework.web.servlet.config.annotation.EnableWebMvc;
8 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
9 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
10 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
11 |
12 | @Configuration
13 | @EnableSpringDataWebSupport
14 | public class WebMvcConfig implements WebMvcConfigurer, WebMvcRegistrations {
15 | //todo implementations
16 | }
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/domain/User.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.domain;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.Id;
9 |
10 | import lombok.*;
11 |
12 | @Entity
13 | @Getter
14 | @NoArgsConstructor
15 | @EqualsAndHashCode(onlyExplicitlyIncluded = true)
16 | public class User implements Serializable {
17 |
18 | @EqualsAndHashCode.Include
19 | @Id
20 | @GeneratedValue
21 | private Long id;
22 |
23 | @EqualsAndHashCode.Include
24 | @Column(nullable = false, unique = true)
25 | private String email;
26 |
27 | @Column(nullable = false)
28 | private String password;
29 |
30 | public User(String email, String password) {
31 | this.email = email;
32 | this.password = password;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/view/annotation/ViewController.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.view.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | import org.springframework.core.annotation.AliasFor;
10 | import org.springframework.stereotype.Controller;
11 |
12 | @Target(ElementType.TYPE)
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Documented
15 | @Controller
16 | public @interface ViewController {
17 |
18 | /**
19 | * The value may indicate a suggestion for a logical component name,
20 | * to be turned into a Spring bean in case of an autodetected component.
21 | * @return the suggested component name, if any
22 | * @since 4.0.1
23 | */
24 | @AliasFor(annotation = Controller.class)
25 | String value() default "";
26 |
27 | }
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/api/UserRestController.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.api;
2 |
3 | import java.util.Optional;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.PathVariable;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | import io.honeymon.boot.springboot.domain.User;
12 | import io.honeymon.boot.springboot.service.UserService;
13 | import lombok.extern.slf4j.Slf4j;
14 |
15 | @Slf4j
16 | @RestController
17 | @RequestMapping("/api/users")
18 | public class UserRestController {
19 |
20 | @Autowired
21 | UserService service;
22 |
23 | @GetMapping("/{id}")
24 | public User findById(@PathVariable long id) {
25 | log.info("Get User: {}", id);
26 | Optional optUser = service.findById(id);
27 |
28 | return optUser.isPresent() ? optUser.get() : new User();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/view/handler/ViewExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.view.handler;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 |
5 | import org.springframework.web.bind.annotation.ControllerAdvice;
6 | import org.springframework.web.bind.annotation.ExceptionHandler;
7 | import org.springframework.web.servlet.ModelAndView;
8 |
9 | import io.honeymon.boot.springboot.view.annotation.ViewController;
10 | import lombok.extern.slf4j.Slf4j;
11 |
12 | /**
13 | * {@link ViewController} 에 대한 예외처리
14 | * @author honeymon
15 | *
16 | */
17 | @Slf4j
18 | @ControllerAdvice(annotations= {ViewController.class})
19 | public class ViewExceptionHandler {
20 |
21 | @ExceptionHandler(Exception.class)
22 | public ModelAndView defaultExceptionHandler(HttpServletRequest req, Exception e) {
23 | log.error("Occurred Exception: {}", e.getMessage());
24 | ModelAndView mav = new ModelAndView("view-error");
25 | mav.addObject("e", e);
26 | mav.addObject("url", req.getRequestURL());
27 | return mav;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/client/HoneymonApiRestTemplateBuilder.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.client;
2 |
3 | import org.springframework.boot.web.client.RestTemplateBuilder;
4 | import org.springframework.http.HttpHeaders;
5 | import org.springframework.http.MediaType;
6 | import org.springframework.web.client.RestTemplate;
7 |
8 | public class HoneymonApiRestTemplateBuilder {
9 | public static RestTemplate build(HoneymonApiProperties properties) {
10 | return new RestTemplateBuilder()
11 | .rootUri(properties.getRootUri())
12 | .defaultHeader(HttpHeaders.AUTHORIZATION, properties.getHeaderAuthorization()) //Authorization: {AuthorizationKey}
13 | .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.getType()) //ContentType: application/json
14 | // .additionalInterceptors(new HoneymonApiHttpInterceptor(properties.getHeaderAuthorization()))
15 | .setReadTimeout(properties.getReadTimeout())
16 | .setConnectTimeout(properties.getConnectTimeout())
17 | .build();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/BootSpringBootApplication.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.WebApplicationType;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.boot.builder.SpringApplicationBuilder;
7 | import org.springframework.boot.context.ApplicationPidFileWriter;
8 | import org.springframework.boot.web.servlet.ServletComponentScan;
9 |
10 | /**
11 | * 스프링 부트 애플리케이션이 시작되는 곳!
12 | * {@link SpringBootApplication}을 살펴보세요. 스프링 부투의 마법이 시작되는 곳입니다.
13 | *
14 | * @author honeymon
15 | *
16 | */
17 | @ServletComponentScan
18 | @SpringBootApplication
19 | public class BootSpringBootApplication {
20 | public static void main(String[] args) {
21 | // SpringApplication.run(BootSpringBootApplication.class, args);
22 |
23 | SpringApplication app = new SpringApplication(BootSpringBootApplication.class);
24 | app.addListeners(new ApplicationPidFileWriter());
25 | //app.setWebEnvironment(false); // 2.0 에서 Deprecated 됨
26 | app.setWebApplicationType(WebApplicationType.SERVLET);
27 | app.run(args);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/webcomponent/HelloFilter.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.webcomponent;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.servlet.Filter;
6 | import javax.servlet.FilterChain;
7 | import javax.servlet.FilterConfig;
8 | import javax.servlet.ServletException;
9 | import javax.servlet.ServletRequest;
10 | import javax.servlet.ServletResponse;
11 | import javax.servlet.annotation.WebFilter;
12 |
13 | @WebFilter("/hello")
14 | public class HelloFilter implements Filter {
15 |
16 | @Override
17 | public void init(FilterConfig filterConfig) throws ServletException {
18 | // TODO Auto-generated method stub
19 |
20 | }
21 |
22 | @Override
23 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
24 | throws IOException, ServletException {
25 |
26 | response.getOutputStream().println("filtering");
27 | response.getOutputStream()
28 | .println("servlet-context-attr:" + request.getServletContext().getAttribute("servlet-context-attr"));
29 |
30 | chain.doFilter(request, response);
31 | }
32 |
33 | @Override
34 | public void destroy() {
35 | // TODO Auto-generated method stub
36 |
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/service/RestClientExampleBean.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.boot.web.client.RestTemplateBuilder;
5 | import org.springframework.stereotype.Service;
6 | import org.springframework.web.client.RestTemplate;
7 |
8 | import lombok.Data;
9 |
10 | @Service
11 | public class RestClientExampleBean {
12 |
13 | private final RestTemplate restTemplate;
14 |
15 | @Autowired
16 | public RestClientExampleBean(RestTemplateBuilder builder) {
17 | this.restTemplate = builder.build();
18 | }
19 |
20 | /**
21 | * 간단한 예제를 만들어보가 찾다보니 나온 사이트.
22 | * JSONPlaceholder
23 | * @param id
24 | *
25 | * @return
26 | */
27 | public Post findOne(long id) {
28 | return this.restTemplate.getForObject("https://jsonplaceholder.typicode.com/posts/{id}", Post.class, id);
29 | }
30 |
31 | @Data
32 | public static class Post {
33 | private Long userId;
34 | private Long id;
35 | private String title;
36 | private String body;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/config/HoneymonApiClientConfig.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.config;
2 |
3 | import io.honeymon.boot.springboot.client.*;
4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
5 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 |
9 | public class HoneymonApiClientConfig {
10 | @Configuration
11 | @ConditionalOnProperty(value = "honeymon.api.client-mode", havingValue = "rest")
12 | @EnableConfigurationProperties({HoneymonApiProperties.class})
13 | public static class HoneymonApiRestClientConfig {
14 | @Bean
15 | public HoneymonApiClient honeymonApiClient(HoneymonApiProperties properties) {
16 | return new HoneymonApiRestClient(properties, HoneymonApiRestTemplateBuilder.build(properties));
17 | }
18 | }
19 |
20 | @Configuration
21 | @ConditionalOnProperty(value = "honeymon.api.client-mode", havingValue = "stub")
22 | public static class HoneymonApiStubClientConfig {
23 | @Bean
24 | public HoneymonApiClient honeymonApiClient() {
25 | return new HoneymonApiStubClient();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/.idea/modules/boot-spring-boot.main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/client/HoneymonApiProperties.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.client;
2 |
3 | import lombok.NoArgsConstructor;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 |
6 | import java.time.Duration;
7 |
8 | @NoArgsConstructor
9 | @ConfigurationProperties("honeymon.api")
10 | public class HoneymonApiProperties {
11 | private String rootUri;
12 | private String headerAuthorization; //header-authorization
13 | private Duration readTimeout;
14 | private Duration connectTimeout;
15 |
16 | public void setRootUri(String rootUri) {
17 | this.rootUri = rootUri;
18 | }
19 |
20 | public void setHeaderAuthorization(String headerAuthorization) {
21 | this.headerAuthorization = headerAuthorization;
22 | }
23 |
24 | public void setReadTimeout(Duration readTimeout) {
25 | this.readTimeout = readTimeout;
26 | }
27 |
28 | public void setConnectTimeout(Duration connectTimeout) {
29 | this.connectTimeout = connectTimeout;
30 | }
31 |
32 | public String getRootUri() {
33 | return rootUri;
34 | }
35 |
36 | public String getHeaderAuthorization() {
37 | return headerAuthorization;
38 | }
39 |
40 | public Duration getReadTimeout() {
41 | return readTimeout;
42 | }
43 |
44 | public Duration getConnectTimeout() {
45 | return connectTimeout;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/.idea/boot-spring-boot.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/test/java/io/honeymon/boot/springboot/service/RestClientExampleBeanTest.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.service;
2 |
3 | import io.honeymon.boot.springboot.service.RestClientExampleBean.Post;
4 | import org.junit.jupiter.api.Test;
5 | import org.junit.jupiter.api.extension.ExtendWith;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.boot.test.context.SpringBootTest;
8 | import org.springframework.test.context.junit.jupiter.SpringExtension;
9 |
10 | import static org.assertj.core.api.Assertions.assertThat;
11 |
12 | /**
13 | * ExtendWith는 JUnit5 에서 반복적으로 실행되는 클래스나 메서드에 선언한다.
14 | * {@link SpringExtension} 클래스는 는 스프링 5에 추가된
15 | * JUnit 5의 주피터(Jupiter) 모델에서 스프링 테스트컨텍스트(TestContext)를 사용할 수 있도록 해준다.
16 | *
17 | * 출처: https://java.ihoney.pe.kr/525 [허니몬(Honeymon)의 자바guru]
18 | *
19 | * https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-testing-spring-boot-applications
20 | */
21 | //@ExtendWith(SpringExtension.class) // JUnit5 와 스프링 부트를 사용한다면 @SpringBootTest 로 대체 가능
22 | @SpringBootTest
23 | public class RestClientExampleBeanTest {
24 |
25 | @Autowired
26 | RestClientExampleBean restClientExampleBean;
27 |
28 | @Test
29 | public void test() {
30 | long postId = 1L;
31 | Post findOne = restClientExampleBean.findOne(postId);
32 |
33 | assertThat(findOne.getId()).isEqualTo(postId);
34 | assertThat(findOne.getUserId()).isEqualTo(1L);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/config/ExampleProperties.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.config;
2 |
3 | import java.net.InetAddress;
4 | import java.util.ArrayList;
5 | import java.util.Collections;
6 | import java.util.List;
7 |
8 | import javax.validation.Valid;
9 | import javax.validation.constraints.NotEmpty;
10 | import javax.validation.constraints.NotNull;
11 |
12 | import org.springframework.boot.context.properties.ConfigurationProperties;
13 | import org.springframework.stereotype.Component;
14 | import org.springframework.validation.annotation.Validated;
15 |
16 | import lombok.AccessLevel;
17 | import lombok.Builder;
18 | import lombok.Data;
19 | import lombok.Getter;
20 | import lombok.NoArgsConstructor;
21 | import lombok.Setter;
22 |
23 | @Component
24 | @Data
25 | @Validated
26 | @ConfigurationProperties("example")
27 | public class ExampleProperties {
28 | private boolean enabled;
29 |
30 | @NotNull
31 | private InetAddress remoteAddress;
32 | @Valid
33 | private final Security security = new Security();
34 |
35 | @NoArgsConstructor(access = AccessLevel.PROTECTED)
36 | @Getter
37 | @Setter
38 | public static class Security {
39 | @NotEmpty
40 | private String username;
41 | private String password;
42 | private List roles = new ArrayList<>(Collections.singleton("USER"));
43 |
44 | @Builder
45 | public Security(String username, String password, List roles) {
46 | this.username = username;
47 | this.password = password;
48 | this.roles = roles;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/config/WebSecurityConfig.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.config;
2 |
3 | import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 | import org.springframework.security.authentication.AuthenticationProvider;
7 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
8 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
9 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
10 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
11 |
12 | @Configuration
13 | @EnableWebSecurity
14 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
15 |
16 | @Override
17 | protected void configure(AuthenticationManagerBuilder auth) throws Exception {
18 | auth.inMemoryAuthentication().withUser("springboot").password("password").roles("USER");
19 | }
20 |
21 | @Override
22 | protected void configure(HttpSecurity http) throws Exception {
23 | http
24 | .requestMatcher(EndpointRequest.toAnyEndpoint())
25 | .authorizeRequests()
26 | .antMatchers("/greeting").anonymous();
27 | }
28 |
29 | @Bean
30 | public AuthenticationProvider authenticationProvider() {
31 | return null;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/io/honeymon/boot/springboot/api/handler/RestResponseEntityExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package io.honeymon.boot.springboot.api.handler;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 |
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.web.bind.annotation.RestControllerAdvice;
8 | import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
9 |
10 | import lombok.AllArgsConstructor;
11 | import lombok.Data;
12 | import lombok.NoArgsConstructor;
13 |
14 | //@RestControllerAdvice(basePackageClasses = HelloController.class)
15 | @RestControllerAdvice
16 | public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
17 |
18 | ResponseEntity> handleControllerException(HttpServletRequest request, Throwable ex) {
19 | HttpStatus status = getStatus(request);
20 | return new ResponseEntity<>(new CustomErrorType(status.value(), ex.getMessage()), status);
21 | }
22 |
23 | private HttpStatus getStatus(HttpServletRequest request) {
24 | Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
25 | if (statusCode == null) {
26 | return HttpStatus.INTERNAL_SERVER_ERROR;
27 | }
28 | return HttpStatus.valueOf(statusCode);
29 | }
30 |
31 | @Data
32 | @NoArgsConstructor
33 | @AllArgsConstructor
34 | public static class CustomErrorType {
35 | private int status;
36 | private String message;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | # default: 공통Common 적용
2 | info:
3 | app:
4 | encoding: \${file.encoding}
5 | java.source: \${java.version}
6 | java.target: \${java.version}
7 | logging:
8 | level:
9 | io.honeymon.boot.springboot: DEBUG
10 | org.springframework.web: TRACE
11 | server:
12 | port: 9000
13 | # ExampleProperties
14 | example:
15 | remote-address: 192.168.1.1
16 | security:
17 | username: admin
18 | roles:
19 | - USER
20 | - ADMIN
21 | spring:
22 | thymeleaf:
23 | cache: false
24 | management:
25 | endpoints:
26 | web:
27 | exposure:
28 | include: "*"
29 | endpoint:
30 | beans:
31 | cache:
32 | time-to-live: 10s
33 | shutdown:
34 | enabled: true
35 | health:
36 | show-details: never
37 | httptrace:
38 | enabled: true
39 | honeymon.api:
40 | root-uri: http://honeymon.io/api
41 | header-authorization: Berear 2019-11-01
42 | read-timeout: 5s
43 | connect-timeout: 10s
44 | client-mode: rest
45 |
46 | ---
47 | spring:
48 | profiles: local
49 | datasource:
50 | url: jdbc:h2:~/.boot-spring-boot;DB_CLOSE_ON_EXIT=FALSE
51 | username: sa
52 | password:
53 | jpa:
54 | hibernate:
55 | ddl-auto: update
56 | honeymon.api:
57 | client-mode: stub
58 |
59 | ---
60 | # test profile 사용시 적용
61 | spring:
62 | profiles: test
63 | datasource:
64 | url: jdbc:h2:mem:test;DB_CLOSE_ON_EXIT=FALSE
65 | username: sa
66 | password:
67 | jpa:
68 | hibernate:
69 | ddl-auto: create-drop
70 | server:
71 | port: ${random.int[8000,9000]}
72 |
73 | ---
74 | # 개발서버 적용
75 | spring:
76 | profiles: dev
77 | datasource:
78 | url: jdbc:mariadb://<>:3306/dev
79 | username: honeymon
80 | password: devhoneymon
81 | jpa:
82 | hibernate:
83 | ddl-auto: validate
84 | server:
85 | port: 9000
86 | honeymon.api:
87 | client-mode: stub
88 |
89 | ---
90 | # 운영서버 적용
91 | spring:
92 | profiles: prd
93 | datasource:
94 | url: jdbc:mariadb://<>:3306/prd
95 | username: honeymon
96 | password: prdhoneymon
97 | jpa:
98 | hibernate:
99 | ddl-auto: validate
100 | server:
101 | port: 5000 # AWS Elastic Beanstalk 에서는 포트번호로 5000번을 사용해야한다.
102 | logging:
103 | level:
104 | io.honeymon.boot.springboot: INFO
105 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.gitignore.io/api/java,gradle,maven,intellij,eclipse
2 |
3 | ### Application ##
4 | *.pid
5 |
6 | ### Maven ###
7 | target/
8 | pom.xml.tag
9 | pom.xml.releaseBackup
10 | pom.xml.versionsBackup
11 | pom.xml.next
12 | release.properties
13 | dependency-reduced-pom.xml
14 | buildNumber.properties
15 | .mvn/timing.properties
16 |
17 |
18 | ### Intellij ###
19 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
20 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
21 | .idea/*.xml
22 |
23 | # User-specific stuff:
24 | .idea/workspace.xml
25 | .idea/tasks.xml
26 | .idea/dictionaries
27 | .idea/vcs.xml
28 | .idea/jsLibraryMappings.xml
29 |
30 | # Sensitive or high-churn files:
31 | .idea/dataSources.ids
32 | .idea/dataSources.xml
33 | .idea/dataSources.local.xml
34 | .idea/sqlDataSources.xml
35 | .idea/dynamic.xml
36 | .idea/uiDesigner.xml
37 |
38 | # Gradle:
39 | .idea/gradle.xml
40 | .idea/libraries
41 |
42 | # Mongo Explorer plugin:
43 | .idea/mongoSettings.xml
44 |
45 | ## File-based project format:
46 | *.iws
47 |
48 | ## Plugin-specific files:
49 |
50 | # IntelliJ
51 | /out/
52 |
53 | # mpeltonen/sbt-idea plugin
54 | .idea_modules/
55 |
56 | # JIRA plugin
57 | atlassian-ide-plugin.xml
58 |
59 | # Crashlytics plugin (for Android Studio and IntelliJ)
60 | com_crashlytics_export_strings.xml
61 | crashlytics.properties
62 | crashlytics-build.properties
63 | fabric.properties
64 |
65 | ### Intellij Patch ###
66 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
67 |
68 | # *.iml
69 | # modules.xml
70 | # .idea/misc.xml
71 | # *.ipr
72 |
73 |
74 | ### Eclipse ###
75 |
76 | .metadata
77 | bin/
78 | tmp/
79 | *.tmp
80 | *.bak
81 | *.swp
82 | *~.nib
83 | local.properties
84 | .settings/
85 | .loadpath
86 | .recommenders
87 |
88 | # Eclipse Core
89 | .project
90 |
91 | # External tool builders
92 | .externalToolBuilders/
93 |
94 | # Locally stored "Eclipse launch configurations"
95 | *.launch
96 |
97 | # PyDev specific (Python IDE for Eclipse)
98 | *.pydevproject
99 |
100 | # CDT-specific (C/C++ Development Tooling)
101 | .cproject
102 |
103 | # JDT-specific (Eclipse Java Development Tools)
104 | .classpath
105 |
106 | # Java annotation processor (APT)
107 | .factorypath
108 |
109 | # PDT-specific (PHP Development Tools)
110 | .buildpath
111 |
112 | # sbteclipse plugin
113 | .target
114 |
115 | # Tern plugin
116 | .tern-project
117 |
118 | # TeXlipse plugin
119 | .texlipse
120 |
121 | # STS (Spring Tool Suite)
122 | .springBeans
123 |
124 | # Code Recommenders
125 | .recommenders/
126 |
127 |
128 | ### Java ###
129 | *.class
130 |
131 | # Mobile Tools for Java (J2ME)
132 | .mtj.tmp/
133 |
134 | # Package Files #
135 | *.jar
136 | *.war
137 | *.ear
138 |
139 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
140 | hs_err_pid*
141 |
142 |
143 | ### Gradle ###
144 | .gradle
145 | /build/
146 |
147 | # Ignore Gradle GUI config
148 | gradle-app.setting
149 |
150 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
151 | !gradle-wrapper.jar
152 |
153 | # Cache of project
154 | .gradletasknamecache
155 |
156 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
157 | # gradle/wrapper/gradle-wrapper.properties
158 |
159 | ### Maven ###
160 | .mvn
161 |
162 | # Avoid ignoring Maven wrapper jar file
163 | !maven-wrapper.jar
164 |
165 | #app
166 | *.pid
167 |
168 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 |
7 | io.honeymon.springboot.boot
8 | boot-spring-boot
9 | 2021.0
10 | jar
11 |
12 | boot-spring-boot
13 | Boot Spring Boot Project
14 | https://github.com/ihoneymon/boot-spring-boot
15 |
16 | honeymon.io
17 | http://honeymon.io
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-parent
23 | 2.4.1
24 |
25 |
26 |
27 |
28 | UTF-8
29 | UTF-8
30 | 1.8
31 | 1.18.16
32 |
33 |
34 |
35 |
36 | org.projectlombok
37 | lombok
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-web
43 |
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-starter-data-jpa
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-starter-security
53 |
54 |
55 |
56 | org.springframework.boot
57 | spring-boot-configuration-processor
58 |
59 |
60 |
61 | org.springframework.boot
62 | spring-boot-starter-validation
63 |
64 |
65 |
66 | com.h2database
67 | h2
68 |
69 |
70 |
71 | org.springframework.boot
72 | spring-boot-starter-tomcat
73 |
74 |
75 |
76 | org.springframework.boot
77 | spring-boot-starter-actuator
78 |
79 |
80 |
81 | org.springframework.boot
82 | spring-boot-starter-test
83 | test
84 |
85 |
86 |
87 |
88 |
89 |
90 | org.springframework.boot
91 | spring-boot-maven-plugin
92 |
93 |
94 |
95 | build-info
96 |
97 |
98 |
99 |
100 |
101 | pl.project13.maven
102 | git-commit-id-plugin
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/README.asc:
--------------------------------------------------------------------------------
1 | = Boot Spring Boot 스프링 부트 시작하기
2 | Honeymon,
3 | v2021.0, 2020-12-26
4 |
5 | :book-name: Boot Spring Boot
6 | :boot-ver: 2.4.1.RELEASE
7 | :maven: 메이븐
8 | :gradle: 그레이들
9 |
10 | ****
11 | [IMPORTANT]
12 | ====
13 | * link:http://bit.ly/2KsJ14G[Boot Spring Boot! 정오표(http://bit.ly/2KsJ14G)]
14 | ====
15 |
16 | 안녕하세요, 허니몬입니다.
17 |
18 |
19 | 이 프로젝트는 {book-name} 책에 담지못한 예제를 구현하기 위해 작성되었습니다.
20 |
21 | * 언어: Java8+
22 | * 기준: link:https://spring.io/projects/spring-boot[Spring Boot {boot-ver}]
23 | * 빌드도구: link:http://maven.apache.org/[{maven}] 혹은 link:https://gradle.org/[{gradle}]
24 | * IDE: link:https://spring.io/tools/sts[STS(Spring Tool Suite,https://spring.io/tools/sts)] 혹은 link:https://www.jetbrains.com/idea/[IntelliJ]
25 | ****
26 |
27 | == 참고
28 | * link:https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/index.html[Spring Framework Documentation]
29 | * link:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/[Spring Boot Reference Guide]
30 | * link:http://projects.spring.io/spring-data/[Spring Data Projects]
31 | ** link:https://docs.spring.io/spring-data/jpa/docs/current/reference/html/[Spring Data JPA - Reference Documentation]
32 | * link:https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle[Spring Security Reference]
33 | * link:https://redis.io/[Redis]
34 | * link:https://docs.mongodb.com/[Welcome to the MongoDB Docs]
35 |
36 |
37 | * link:https://github.com/ihoneymon/honeymon-spring-boot-starter[`honeymon-spring-boot-starter`(https://goo.gl/RTtZ2q)]
38 | +
39 | [NOTE]
40 | ====
41 | 아는 형의 요청으로 ``spring-boot-starter``를 사용자 정의하여 만드는 예제를 포함하고 있는 프로젝트다. ``spring-boot-starter``는 ``spring-boot-autoconfigure`` 내에 ``~~AutoConfiguration``과 ``~~Properties`` 클래스가 함께 존재하며 자동구성 클래스라는 것을 정의하는 ``spring.factories`` 설정파일과 애플리케이션 속성파일에서 자동완성을 지원하기 위해 ``additional-spring-configuration-metadata.json``이 함께 필요하다.
42 |
43 | 사용자정의 ``spring-boot-starter``는 사내에서 프라이빗한 공통사항을 starter로 만들어 스프링 부트 기반으로 애플리케이션 개발시 요긴하게 사용할 수 있다.
44 | ====
45 |
46 | * link:http://jojoldu.tistory.com/category/Spring[http://jojoldu.tistory.com/category/Spring] - 기억보단 기록을
47 | +
48 | [NOTE]
49 | ====
50 | 최근 가장 눈에 띄는 스프링 부트 관련 글들을 포스팅하고 있는 블로그다. '스프링 부트로 웹 서비스 출시하기' 시리즈는 AWS에 애플리케이션을 배포하는 과정을 잘 설명하고 있으며 전체적인 설명과 그림이 충실하여 좋다.
51 |
52 | 저서 link:http://www.yes24.com/Product/Goods/83849117['스프링 부트와 AWS로 혼자 구현하는 웹 서비스'] 출간
53 | ====
54 |
55 | * link:http://javacan.tistory.com/category/Spring%2C%20JPA%2C%20ORM[Javacan(http://javacan.tistory.com)]
56 | +
57 | [NOTE]
58 | ====
59 | 국내에서 자바 개발분야에서 넓은 시각을 가지고 빠르게 접근할 수 있는 책을 많이 기술하시는 범균님의 블로그다. 스프링 부트를 비롯하여 스프링과 다양한 기술 지식을 얻을 수 있다.
60 | ====
61 |
62 | * link:https://spring.io/blog[https://spring.io/blog]
63 | +
64 | [NOTE]
65 | ====
66 | 스프링에 대한 최신 정보는 이 곳에서 얻어볼 수 있다.
67 | ====
68 |
69 | * link:https://github.com/spring-projects/[https://github.com/spring-projects/]
70 | +
71 | [NOTE]
72 | ====
73 | Spring 프로젝트의 오픈된 소스를 확인할 수 있는 깃헙 저장소다.
74 | ====
75 |
76 |
77 | * YOUTUBE 채널
78 | ** link:https://www.youtube.com/playlist?list=PLagTY0ogyVkKepHNpChFT3cQnarhpqPP0[허니몬의 'Boot Spring Boot']
79 | +
80 | [NOTE]
81 | ====
82 | 제 책 'Boot Spring Boot'와 관련한 내용과 Spring Boot 관련한 영상기록모음 입니다.
83 | ====
84 |
85 | ** link:https://www.youtube.com/user/whiteship2000[백기선님 유투브]
86 | +
87 | [NOTE]
88 | ====
89 | 최근 스프링 부트 2.0 레퍼런스 문서를 읽으면서 코딩을 곁들여서 방송하고 계십니다.
90 | 책이 나오면 저도 비슷한 형식으로 해보려고 했는데 저보다 훨씬 잘하고 계셔서 감사하게 보고 있습니다.
91 | ====
92 |
93 | ** link:https://www.youtube.com/channel/UCsOJxLxzQl8IbwGS-Cp5t8w[캐빈 TV]
94 | +
95 | [NOTE]
96 | ====
97 | 호주에 계신 스칼라(?) 개발자 '캐빈'님의 IT예능 방송채널
98 | ====
99 |
100 | ** link:https://www.youtube.com/user/springcampkr[springcamp.io - Youtube]
101 | +
102 | [NOTE]
103 | ====
104 | Spring Camp 2013을 시작으로 자바 백엔드 기술에 대한 다양한 발표기록이 남아있다.
105 | ====
--------------------------------------------------------------------------------
/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin or MSYS, switch paths to Windows format before running java
129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=$((i+1))
158 | done
159 | case $i in
160 | (0) set -- ;;
161 | (1) set -- "$args0" ;;
162 | (2) set -- "$args0" "$args1" ;;
163 | (3) set -- "$args0" "$args1" "$args2" ;;
164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=$(save "$@")
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185 | cd "$(dirname "$0")"
186 | fi
187 |
188 | exec "$JAVACMD" "$@"
189 |
--------------------------------------------------------------------------------
/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------
/src/main/resources/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Install PackagesBoot Spring Boot 스프링 부트 시작하기
5 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
Boot Spring Boot 스프링 부트 시작하기
450 |
451 |
452 |
496 |
497 |
498 |
Table of Contents
499 |
502 |
503 |
504 |
505 |
참고
506 |
507 |
508 |
509 |
510 | Spring Framework Documentation
511 |
512 |
513 | Spring Boot Reference Guide
514 |
515 |
516 | Spring Data Projects
517 |
524 |
525 |
526 | Spring Security Reference
527 |
528 |
529 | Redis
530 |
531 |
532 | Welcome to the MongoDB Docs
533 |
534 |
535 | honeymon-spring-boot-starter(https://goo.gl/RTtZ2q)
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
아는 형의 요청으로 spring-boot-starter를 사용자 정의하여 만드는 예제를 포함하고 있는 프로젝트다. spring-boot-starter는 spring-boot-autoconfigure 내에 ~~AutoConfiguration과 ~~Properties 클래스가 함께 존재하며 자동구성 클래스라는 것을 정의하는 spring.factories 설정파일과 애플리케이션 속성파일에서 자동완성을 지원하기 위해 additional-spring-configuration-metadata.json이 함께 필요하다.
545 |
546 |
547 |
사용자정의 spring-boot-starter는 사내에서 프라이빗한 공통사항을 starter로 만들어 스프링 부트 기반으로 애플리케이션 개발시 요긴하게 사용할 수 있다.
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 | http://jojoldu.tistory.com/category/Spring - 기억보단 기록을
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
최근 가장 눈에 띄는 스프링 부트 관련 글들을 포스팅하고 있는 블로그다. '스프링 부트로 웹 서비스 출시하기' 시리즈는 AWS에 애플리케이션을 배포하는 과정을 잘 설명하고 있으며 전체적인 설명과 그림이 충실하여 좋다.
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 | Javacan(http://javacan.tistory.com)
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
국내에서 자바 개발분야에서 넓은 시각을 가지고 빠르게 접근할 수 있는 책을 많이 기술하시는 범균님의 블로그다. 스프링 부트를 비롯하여 스프링과 다양한 기술 지식을 얻을 수 있다.
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 | https://spring.io/blog
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
스프링에 대한 최신 정보는 이 곳에서 얻어볼 수 있다.
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 | https://github.com/spring-projects/
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
Spring 프로젝트의 오픈된 소스를 확인할 수 있는 깃헙 저장소다.
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 | YOUTUBE 채널
624 |
625 |
626 |
627 | 허니몬의 'Boot Spring Boot'
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
제 책 'Boot Spring Boot’와 관련한 내용과 Spring Boot 관련한 영상기록모음 입니다.
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 | 백기선님 유투브
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
최근 스프링 부트 2.0 레퍼런스 문서를 읽으면서 코딩을 곁들여서 방송하고 계십니다.
654 | 책이 나오면 저도 비슷한 형식으로 해보려고 했는데 저보다 훨씬 잘하고 계셔서 감사하게 보고 있습니다.
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 | 캐빈 TV
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
호주에 계신 스칼라(?) 개발자 '캐빈’님의 IT예능 방송채널
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 | springcamp.io - Youtube
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
Spring Camp 2013을 시작으로 자바 백엔드 기술에 대한 다양한 발표기록이 남아있다.
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
--------------------------------------------------------------------------------