All Projects → ihoneymon → honeymon-spring-boot-starter

ihoneymon / honeymon-spring-boot-starter

Licence: other
Simple Spring Boot Starter and Summary

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to honeymon-spring-boot-starter

Cassandre Trading Bot
Cassandre makes it easy to create your Java crypto trading bot. Our Spring boot starter takes care of exchange connections, accounts, orders, trades, and positions.
Stars: ✭ 120 (+500%)
Mutual labels:  spring-boot-starter
Opentracing Toolbox
Best-of-breed OpenTracing utilities, instrumentations and extensions
Stars: ✭ 161 (+705%)
Mutual labels:  spring-boot-starter
localstack-spring-boot-starter
SpringBoot Starter for Localstack
Stars: ✭ 38 (+90%)
Mutual labels:  spring-boot-starter
Jasypt Spring Boot
Jasypt integration for Spring boot
Stars: ✭ 1,948 (+9640%)
Mutual labels:  spring-boot-starter
Grpc Spring Boot Starter
Spring Boot starter module for gRPC framework.
Stars: ✭ 2,190 (+10850%)
Mutual labels:  spring-boot-starter
Riptide
Client-side response routing for Spring
Stars: ✭ 169 (+745%)
Mutual labels:  spring-boot-starter
Wicket Spring Boot
Spring Boot starter for Apache Wicket
Stars: ✭ 117 (+485%)
Mutual labels:  spring-boot-starter
shiro-pac4j-spring-boot-starter
pac4j + shiro
Stars: ✭ 14 (-30%)
Mutual labels:  spring-boot-starter
Cas Client Autoconfig Support
Annotation-based configuration support for Apereo CAS Java clients
Stars: ✭ 153 (+665%)
Mutual labels:  spring-boot-starter
weixin-sdk
www.docs4dev.com/
Stars: ✭ 19 (-5%)
Mutual labels:  spring-boot-starter
Spring Backend Boilerplate
The modularized backend boilerplate based on Spring Boot Framework, easy to get started and add your business part.
Stars: ✭ 134 (+570%)
Mutual labels:  spring-boot-starter
Justauth Spring Boot Starter
Spring Boot 集成 JustAuth 的最佳实践~
Stars: ✭ 143 (+615%)
Mutual labels:  spring-boot-starter
Rocketmq Spring Boot Starter
rocketmq-spring-boot-starter
Stars: ✭ 178 (+790%)
Mutual labels:  spring-boot-starter
Bucket4j Spring Boot Starter
Spring Boot Starter for Bucket4j
Stars: ✭ 127 (+535%)
Mutual labels:  spring-boot-starter
logback-access-spring-boot-starter
Spring Boot Starter for Logback-access.
Stars: ✭ 153 (+665%)
Mutual labels:  spring-boot-starter
Logback Access Spring Boot Starter
Spring Boot Starter for Logback-access
Stars: ✭ 118 (+490%)
Mutual labels:  spring-boot-starter
Tutorial Soap Spring Boot Cxf
Tutorial how to create, test, deploy, monitor SOAP-Webservices using Spring Boot and Apache CXF
Stars: ✭ 167 (+735%)
Mutual labels:  spring-boot-starter
memcached-spring-boot
Library that provides support for auto-configuration of Memcached cache in a Spring Boot application.
Stars: ✭ 68 (+240%)
Mutual labels:  spring-boot-starter
faucet-pipeline-spring-boot-starter
faucet-pipeline for Spring Boot
Stars: ✭ 17 (-15%)
Mutual labels:  spring-boot-starter
Graphql Spqr Spring Boot Starter
Spring Boot 2 starter powered by GraphQL SPQR
Stars: ✭ 187 (+835%)
Mutual labels:  spring-boot-starter

Spring Boot 시작하기

스프링 부트 소개

스프링 기반의 애플리케이션을 개발부터 운영까지 빠르게 진행할 수 있는 개발플랫폼

  • JVM 기반 언어 Java, Kotlin 과 Groovy 지원

  • 빌드도구: 메이븐과 그레이들

  • 쉽고 빠른 기능 추가: 스프링 부트 스타터

  • 배포를 위한 외부 구성(External Configuration) 지원

  • 운영관리를 위한 모니터링 및 관리도구 지원

스프링 부트는 새로운 버전이 출시될 때마다 지원하는 라이브러리의 버전들도 함께 갱신된다. 이에 대한 정보는 spring-boot-dependencies(https://goo.gl/wKCxQ1)를 살펴보면 된다.

BOM(Bill of Materials)

스프링 부트 배포시 사용하는 3rd Party 라이브러리의 버전을 함께 관리해야하는데 이와 관련된 기능을 BOM 이라고 설명하고 있다.

스프링 부트 구성

Spring Boot = BuildTools(Maven, Gradle) (Spring Boot Plugin + Spring + Auto Configuration + Starter)

Spring Boot Application 의 시작점: @SpringBootApplication

  • @SpringBootApplication: 아래 3가지 애너테이션이 조합되어 스프링 부트의 마법이 시작되는 지점이다.

    • @EnableAutoConfiguration

    • @ComponentScan

    • @SpringBootConfiguration(@Configuration)

  • 스프링 부트는 XML 설정파일을 사용하지 않는다.

  • 자바 구성(Java Config) 및 애너테이션 기반으로 애플리케이션을 구성한다.

  • AnnotationConfigApplicationContext

빠른 기능추가: 스타터(spring-boot-starters)

자동구성(Auto-Configuration)

@ConditonOn* 조건처리 애너테이션

@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass({ Servlet.class, DispatcherServlet.class,
		WebMvcConfigurerAdapter.class })
@ConditionalOnMissingBean(WebMvcConfigurationSupport.class)
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE + 10)
@AutoConfigureAfter({ DispatcherServletAutoConfiguration.class,
		ValidationAutoConfiguration.class })
public class WebMvcAutoConfiguration {
  //
  • 패키지: org.springframework.boot.autoconfigure.condition

    • 대표적인 조건클래스

      • @ConditionOnClass: 지정한 클래스가 있을 때!

      • @ConditionOnMissingClass: 지정한 클래스가 없을 때!

      • @ConditionOnBean: 지정한 빈이 있을 때!

      • @ConditionOnMissingBean: 지정한 빈이 없을 때!

      • …​

확장 구성(External Configuration)

  • 작명규칙: ~Properties

  • @ConfigurationProperties

AntiPangProperties
@Getter
@Setter
@NoArgsConstructor(access=AccessLevel.PROTECTED)
@ConfigurationProperties("io.honeymon.antipang")
public class AntiPangProperties {
	private String name = "honeymon";
	private String email = "[email protected]";
	private String siteUrl = "http://honeymon.io";

	public AntiPangProperties(String name, String email, String siteUrl) {
		this.name = name;
		this.email = email;
		this.siteUrl = siteUrl;
	}
}

확장 구성을 통해 속성변경할 필요가 없는 비공개 속성이라면!

  • @PropertiesSource를 이용해서 .properties 파일을 읽어온다.

honeymon-spring-boot-starter

스프링 부트에서 제공하는 스타터(Starter)(https://goo.gl/AFuTqQ)) 외에도 개발자가 자신에게 필요한 구성을 자동구성(Auto-Configuration)한 스타터를 이용할 수 있다.

antipang-spring-boot-autoconfigure

  • META-INF/spring.factories: 스프링 부트 애플리케이션 설정

  • AntiPangAutoConfiguration: 자동구성(Auto Configuration) 클래스

  • AntiPangProperties: 자동구성 외부설정이 가능하도록 해주는 역할수행

  • META-INF/additional-spring-configuration-metadata.json: IDE 속성구성 자동완성을 지원하는 MetaData 작성 참조

IDE 속성구성 자동완성을 지원하는 MetaData 작성

구성속성 자동완성 지원

antipang-spring-boot-starter

  • Nexus 저장소에 배포를 실행할 래퍼(Wrapper) 프로젝트

  • 별다른 게 없죠. @_@);

스프링 부트 애플리케이션 실행전략

스프링 부트 애플리케이션을 실행하는 전략은 다양하다. 배포운영하는 방법에 따라서 적절한 방식을 선택하면 된다. 이에 대해서는

빌드도구 플러그인을 이용해서 실행하는 방법

//Maven
$ ./mvnw spring-boot:run
//Gradle
$ ./gradlew bootRun

시스템속성값 (-D{property}={value}) 이용하기

build.gradle
bootRun {
    systemProperties System.properties  // (1)
}
  1. bootRun이 실행될 때 시스템 속성값을 JVM의 System.prpoerties 값을 사용하도록 정의

위에서 bootRun의 속성을 부여하면 다음과 같이 실행하는 것이 가능함

$ ./gradlew bootRun -Dserver.port=9000

실행가능한 Jar

스프링 부트는 빌드도구를 통해 제공하는 스프링 부트 플러그인을 통해 프로젝트를 재구성하여 빌드한다. $PROJECT_HOME/build/libs 디렉토리를 보면 원래 패키징된 {project-name}.jar.original 파일과 리패키징된 {project-name}.jar가 있다. 두 가지 파일은 각각 ZIP 형식으로 압축을 해제해보면 어떤 구조를 하고 있는지 살펴볼 수 있다.

.jar.original 파일
.
├── application.yml
├── io
│   └── honeymon
│       └── boot
│           └── antipang
│               └── app
│                   ├── AntiPangApplication.class
│                   └── config
│                       ├── LocalAppConfig$AntiPang.class
│                       └── LocalAppConfig.class
├── META-INF
│   └── MANIFEST.MF
├── static
└── templates
.jar 파일
.
├── BOOT-INF
│   ├── classes
│   │   ├── application.yml
│   │   ├── io
│   │   │   └── honeymon
│   │   │       └── boot
│   │   │           └── antipang
│   │   │               └── app
│   │   │                   ├── AntiPangApplication.class
│   │   │                   └── config
│   │   │                       ├── LocalAppConfig$AntiPang.class
│   │   │                       └── LocalAppConfig.class
│   │   ├── static
│   │   └── templates
│   └── lib
│       ├── antipang-spring-boot-autoconfigure-0.0.1-SNAPSHOT.jar
│       ├── antipang-spring-boot-starter-0.0.1-SNAPSHOT.jar
│       └── 생략
├── META-INF
│   └── MANIFEST.MF
└── org
    └── springframework
        └── boot
            └── loader
                ├── archive
                │   └── Jar 파일 내부를 탐색
                ├── data
                │   └── RandomAccess...
                ├── ExecutableArchiveLauncher$1.class
                ├── ExecutableArchiveLauncher.class
                ├── jar
                │   └── Jar 파일을 읽고 접근
                ├── JarLauncher.class
                ├── LaunchedURLClassLoader$1.class
                ├── LaunchedURLClassLoader.class
                ├── Launcher.class
                ├── MainMethodRunner.class
                ├── PropertiesLauncher$1.class
                ├── PropertiesLauncher$ArchiveEntryFilter.class
                ├── PropertiesLauncher.class
                ├── PropertiesLauncher$PrefixMatchingArchiveFilter.class
                ├── util
                │   └── SystemPropertyUtils.class
                └── WarLauncher.class
Note

스프링 부트 리패키징을 통해서 자바 애플리케이션을 필요한 라이브러리를 하나로 묶어서 실행가능한 jar로 묶어 배포본을 생성한다. 이렇게 생성된 배포본은 JVM이 실행가능한 환경이면 어디서든지 실행이 가능하다.

이 부분이 스프링 부트의 확장포인트!! 어떻게 사용할 수 있을지 고민해보자.

정리

스프링 부트를 이용하기 위해서는,

  • 스프링 부트 레퍼런스를 한번 쭈욱 읽어주시고

  • 스프링 부트 자동구성 클래스가 모여있는 org.springframework.boot.autoconfigure 패키지(spring-boot-autoconfigure(https://goo.gl/ydcqY3)를 살펴봅니다.

    • 생각했던 것과는 다르게 동작하는 경우가 있다면, 추가한 스타터의 자동구성이 의도와 다르게 구성되어 있는 경우가 많음

    • 그럴 때는 스프링 부트 레퍼런스=부록(공통 애플리케이션 속성 을 살펴보고 속성을 살펴봅니다.

    • 간혹 문서에 나와있는 기본속성이 코드에서는 다르게 구현되어 있는 경우도 있음

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].