반응형

스프링 부트 1.5 릴리즈 노트

원문: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.5-Release-Notes

스프링 부트 1.4에서 업그레이드된 것

스프링부트 1.4이후 디프리케이트된것들

스프링부트 1.4에서 디프리케이트된 클래스, 메소드 그리고 프로퍼티들이 이번 릴리즈에서 제거되었다. 업그레이드전 디프리케이트된 메소드를 호출하는지 확인하자. 특히 HornetQ와 벨로시티 Velocity서포트가 삭제되었다.


이름이 바뀐 스타터들

스프링부트 1.4에서 이름이 바뀐 다음의 스타터들이 이번에 삭제되었다. 만일 "해결할수 없는 의존성 Unresolved dependency" 에러가 뜬다면 사용중인 스타터 이름이 올바른지 확인해보자:

  • spring-boot-starter-ws → spring-boot-starter-web-services

  • spring-boot-starter-redis → spring-boot-starter-data-redis

@ConfigurationProperties validation

JSR-303 규약 어노테이션을 사용하는 @ConfigurationProperties 클래스를 가지고 있다면 이제 그것들에 추가적으로 @Validated 어노테이션을 해줘야한다. 이미 있는 유효성은 여전히 잘 동작할것이지만 로그에 warning이 뜬것이다. 머지않아 @Validated 이 없는 클래스는 사용할 수 없을 것이다. 

스프링 세션 저장 Spring Session store

이제껏 스프링 세션과 레디스를 특별한 설정없이 사용해왔다면, 레디스는 자동으로 세션을 저장하는데 사용되었다. 이제는 저장 타입을 명시해주어야한다. 레디스와 스프링 세션을 사용하는 사용자들은 다음의 설정을 추가 해주어야한다:

spring.session.store-type=redis

액츄에이터 보안 Actuator security

Actuator "sensitive" endpoints are now secure by default (even if don’t have a dependency on "Spring Security"). If your existing Spring Boot 1.4 application makes use of Spring Security (and doesn’t have any custom security configuration) things should work as before. If your existing Spring Boot 1.4 application has custom security configuration and you wish to have open access to your sensitive endpoints, you will need to explicitly configure that in your security configuration. If you’re upgrading a Spring Boot 1.4 application that doesn’t have dependency on Spring Security and you wish to retain open access to your sensitive endpoints you’ll need to set management.security.enabled to false. See the updated reference documentation for more details.

The default role required to access the endpoints has also changed from ADMIN to ACTUATOR. This is to prevent accidental exposure of endpoints if you happen to use the ADMIN role for other purposes. If you want to restore Spring Boot 1.4 behavior set the management.security.roles property to ADMIN.

인메모리 매트릭스 리파지토리 InMemoryMetricRepository

InMemoryMetricRepository는 더이상 직접적으로 MultiMetricRepository를 구현하지않는다.  정식 InMemoryMetricRepository에 의해 뒷받침되어 MultiMetricRepository 인터페이스를 만족시키는 새로운 InMemoryMultiMetricRepository 빈이 이제 등록되었다. 대부분의 사용자가 MetricRepository 또는 MultiMetricRepository 인터페이스를 사용하고 있으므로 이 변화는 직접 보여지지않는다.  

spring.jpa.database

The spring.jpa.database 는 spring.datasource.url 프로퍼티를 통한 일반적인 데이터 베이스를 자동으로 찾아준다. 만일 spring.jpa.database를 수동으로 정의하며 사용해왔고 일반적인 데이터베이스를 사용하고 있다면 이 프로퍼티들을 다 없애버려도 될것이다.

하나 이상의 Dialect 를 가진 몇몇의 데이터베이스 (이를테면 Microsoft SQL Server 는 3개를 가지고있다) 그리고 당신이 사용중인 데이터베이스의 버젼이 설정한 것과 맞지 않는다면, 이전에 잘 작동한 설정을 가지고 하이버네이트의 Dialect자동 찾기에 맡기기 원한다면 spring.jpa.database=default 로 설정하자. 대안으로  spring.jpa.database-platform 프로퍼티를 사용하여 당신의 dialect를 설정할 수 있다.

@IntegrationComponentScan

스프링 Integration의 @IntegrationComponentScan 어노테이션은 이제 자동 설정된다. 권장되는 프로젝트 구조를 따른다면 당신은 이것을 지워줘야한다.

ApplicationStartedEvent

현재 당신의 코드에서 ApplicationStartedEvent를 위한 리스너 listener가 있다면,  ApplicationStartingEvent를 쓰도록 코드를 리팩토링 해주어야한다. 우리는 이 클래스가 무엇을 하는지 더 정확하게 알수 있게 이름을 바꾸었다.

Spring Integration Starter

spring-boot-starter-integration POM 은 더이상 spring-integration-jmx를 포함되지 않는다. 만일 당신이 Spring Integration JMX support가 필요하다면 spring-integration-jmx 의존성을 스스로 추가해줘어야한다.

Devtools excluded by default

메이븐과 그레들 플러그인 둘다 이제 기본적으로 "fat" jars에 spring-boot-devtools jar를 패키징 하지않는다. 당신이 devtools 원격 서포트를 사용중이라면, 이제 당신의 build.gradle 또는 pom.xml 파일에 excludeDevtools 프로퍼티를 명시적으로 설정해주어야한다.

Gradle 1.x

스프링 부트 그래들 플러그인은 이제 더이상 그래들 1.x와 그래들 2.x 초기버전과 호환되지 않는다. 그래들 2.9 이상 버전인지 확인하자.

Remote CRaSH shell

불행히도 remote SSH support을 제공하고저 스프링부트에서 사용하는 CRaSH project 는 더이상 유지가 되지않고 있으므로 우리는 remote actuator SSH support을 디프리케이트 하기로 결정하였고 스프링 부트 2.0에서 완전히 제거될 예정이다.

OAuth 2 Resource Filter

OAuth2 리소스 필터의 기본 순서가 3에서 SecurityProperties.ACCESS_OVERRIDE_ORDER - 1 로 변경되었다. 이 지점은 the actuator endpoints 바로 뒤이고 basic authentication filter chain 전이다. 이 기본값은 security.oauth2.resource.filter-order = 3 으로 설정하면 예전값으로 되돌릴 수 있다.

JSP servlet

JSP 서블릿응ㄴ 이제 더이상 기본값으로 개발모드가 아니다. 개발 모드는 DevTools을 쓸때 자동적으로 활성화 된다.  server.jsp-servlet.init-parameters.development=true.설정을 통해 명시적으로 활성화 할 수도 있다. 

Ignored paths and @EnableWebSecurity

스프링 부트 1.4 또는 이전 버전에서 Actuator는 항상 어떤 Ignored paths를 설정하여 @EnableWebSecurity의 사용을 무시해왔다. 이것은 1.5에서 바로 잡았으며  @EnableWebSecurity 를 사용하면 당신에게 완전한 제어가 가능했던 웹 보안의 자동 설정이 꺼질 것이다.

새로운 사항 및 주목할만한 점

Tip
Check the configuration changelog for a complete overview of the changes in configuration.

Third-party library upgrades

서드파티 라이브러리의 버전이 최신 버젼으로 업그레이드 되었다. 이 업데이트는 pring Data Ingalls, Jetty 9.4, JooQ 3.9, AssertJ 2.6.0, Hikari 2.5 그리고 Neo4J 2.1 이며 몇몇 메이븐 플러그인도 업그레이드 되었다.

Loggers endpoint

새로운 액츄에이터 loggers endpoint는 동작중인 어플리케이션의 로깅 레벨을 바꿀수 있게 해준다. 이는 JMX와 MVC endpoint에도 사용할수있다. 예를 들면 MVC endpoint의 로깅레벨을 바꾸려면 다음의 JSON를 /loggers/com.yourcorp.application에  post로 이슈해주면 된다:

{
  "configuredLevel": "DEBUG"
}

JMX endpoint를 사용하는 로거를 업데이트하려면  setLogLevel 를 사용하면 되는데 자세한 사항은 the updated documentation에서 확인하자.

Apache Kafka support

스프링 부트 1.5는 spring-kafka프로젝트를 통해 아파치 Kafka 자동설정을 지원한다. 손쉽게 Kafka를 사용하려면  spring-kafka 의존성과 `spring.kafka.* 어플리케이션 프로퍼티를 적절하게 설정해주면 된다.

Kafka로 부터 메세지를 받으려면 어노테이션 메소드를 쓰는게 제일 간단하다: 

@Component
public class MyBean {

    @KafkaListener(topics = "someTopic")
    public void processMessage(String content) {
        // ...
    }

}

Cloud Foundry actuator extensions

Spring Boot’s actuator module now includes additional support that is activated when you deploy to a compatible Cloud Foundry instance. The /cloudfoundryapplication path provides an alternative secured route to all NamedMvcEndpoint beans.

Cloud Foundry management UIs can make use of the endpoint to display additional actuator information. For example, Pivotal Cloud Foundry shows health information next to the application status:

apps manager

You can read more about the Cloud Foundry endpoint in the reference documentation and for and example of the kinds of things it can be used for you can read this blog post about PCF 1.9.

LDAP support

스프링 부트는 이제 어떤 표준 규약을 따르는 LDAP 서버를 자동설정해준다. 뿐만 아니라 Unbounded를 사용하여 내장 인메모리 LDAP 서버를 지원한다.

자세한 사항은 the documentation를 확인하자.

AuditEvents Endpoint Support

A new AuditEventsJmxEndpoint bean now allows you to query previously recorded AuditEvents over JMX. The MBean exposes AuditEventRepository find methods via getDataoperations. Audits are automatically recoded for authentication and authorization event and you can record your own events using the AuditEventRepository. That information is also exposed by a new /auditevents MVC endpoint.

Transaction manager properties

이제  spring.transaction.* 프로퍼티를 사용하여 PlatformTransactionManager를 자동설정해주는 다양한 aspects를 설정하는것이 가능해졌다. 현재는 "default-timeout" 과  rollback-on-commit-failure 프로퍼티가 지원된다.

JmxEndpoint interface

새로운 JmxEndpoint 인터페이스가 소개되어 당신이 액츄에이터 actuator endpoint를 JMX를 통해서만 노출되도록 개발할 수 있다. 이 인터페이스는 이미 MVC only endpoint를 제공해주는  MvcEndpoint 인터페이스와 매우 유사하다.

Vendor specific flyway migrations

You can now define flyway migration that are specific to a database vendor. To use vendor specific migrations, set the flyway.locations property as follows:

flyway.locations=db/migration/{vendor}

See this how-to for more details.

Deprecation level

It is now possible to define a deprecation level for a property in the metadata. The level can either be warning (default) or error.

Here is an example of manual metadata for a property that got moved in Spring Boot 2:

{
  "name": "server.context-parameters",
  "type": "java.util.Map<java.lang.String,java.lang.String>",
  "description": "ServletContext parameters.",
  "deprecation": {
    "level": "error",
    "replacement": "server.servlet.context-parameters"
  }
}

So far, when a deprecated property is not bound anymore, we remove the metadata altogether. This new feature allows to flag a property (server.context-parameters here) as an error. Newer versions of your favorite IDE should use that to offer assistance.

테스팅 업데이트 Testing updates

이제 @Test…​a로 시작하는 어노테이션에 의해 임포트import되던 자동설정을 제외할 수 있게 되었다. 모든 현존하는  @Test…​어노테이션들은 이제 excludeAutoConfiguration 속성값을 가지게 되었다. 또 다른 방법으로 당신의 테스트코드에 직접적으로  @ImportAutoConfiguration(exclude=…​)를 추가해줘도 된다.

스프링 부트 1.5에서 새로운 @JdbcTest 어노테이션이 소개되어 직접 JDBC과 상호연동되는 테스트를 할 수 있다.

Custom fat jar layouts

스프링 부트 메이븐과 그래들 플러그인은 이제 far jar 레이아웃을 커스터마이즈할 수 있게 지원한다. 이 기능은 스프링부트의 영역 밖에서 개발된  다음과 같은 실험적인 레이아웃을 가능하게 해준다. 더 자세한 업데이트된 문서를 참고하자

JmsTemplate customizations

이제  spring.jms.template.* 네임스페이스의 추가된 키값을 사용하여 자동설정된  JmsTemplate을 커스터마이즈 할수 있게 되었다.

Miscellaneous

  • Mockito 2.x 은 이제  @MockBean 으로 사용할 수 있다.(Mockito 1.9 와 호환가능함)

  • 내장 런쳐 스크린트는 이제 a force-stop을 지원한다. 

  • 카산드라를 위한 새로운 health check가 추가되었다.

  • 카산드라 사용자 정의 타입들이 이제 해결되었다. (스프링 데이터의 SimpleUserTypeResolver를 통해)

  • The skip 프로퍼티는 이제  스프링 부트 메이븐 플러그인  run 에서, 'stop' 그리고 'repackage` goals 에서 사용할 수 있다.

  • 복수개의 main m메소드 클래스가 있다면, 메이븐과 그래들 플러그인은 이제 자동적으로  @SpringBootApplication 어노테이션이 있는것을 실행할 것이다.

Deprecations in Spring Boot 1.5

  • TomcatEmbeddedServletContainerFactory.setTldSkip has been deprecated in favor of setTldSkipPatterns

  • ApplicationStartedEvent has been replaced by ApplicationStartingEvent

  • Several constants in LoggingApplicationListener have been replaced by versions in LogFile

  • Caching with Guava has been deprecated since Guava support will be dropped in Spring Framework 5. Upgrade to Caffeine

  • CRaSH support has been deprecated since it’s no longer actively maintained

  • Several protected methods in EndpointMBeanExporter have been deprecated following the introduction of JmxEndpoint

  • SearchStrategy.PARENTS has been replaced with SearchStrategy.ANCESTORS.

  • Apache DBCP support has been deprecated in favor of DBCP 2

  • The server.undertow.buffers-per-region property has been deprecated because it is not used (see UNDERTOW-587)

  • @AutoConfigureTestDatabase has been moved from org.springframework.boot.test.autoconfigure.orm.jpa to org.springframework.boot.test.autoconfigure.jdbc

프로퍼티 이름변경 Property Renames

  • server.max-http-post-size 프로퍼티는 특정기술 형태값으로 바뀌었다. (예를 들면, server.tomcat.max-http-post-size)

  • spring.data.neo4j.session.scope 프로퍼티는 제거되었다.


반응형

반응형

스프링 부트 1.4 릴리즈 노트 - 2017년 1월 19일

원문: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.4-Release-Notes

스프링부트 1.3이후 업그레이드된 것

스프링 부트 1.3에서 더이상 지원하지않는 것 Deprecations from Spring Boot 1.3

스프링 부트 1.3에서 디프리케이트된 클래스, 메소드, 프로퍼티들은 이번 릴리즈에서 제거되었다.업그레이드에 앞서 디프리케이트된 메소드를 호출하는지 먼저 확인해야한다.

Log4j 1 지원은 Apache EOL announcement 의거하여 제거되었다.

재명명된 스타터들 Renamed starters

다음의 스타터들의 이름이 변경되었다.기존의 이름은 스프링 부터 2.0에서 제거될 것이다.

  • spring-boot-starter-ws → spring-boot-starter-web-services

  • spring-boot-starter-redis → spring-boot-starter-data-redis

DataSourceProperties의 get 메소드들 DataSourceProperties get methods

DataSourceProperties의 몇몇 get…​ 메소드들은 다른 @ConfigurationProperties 클래스들과 더 일관성있게 바뀌었다. 만약 이전에 다음의 메드들을 코드에 직접적으로 호출했었다면 동일한 기능의 새 determine…​로 바꿔줘야한다.

  • getDriverClassName() → determineDriverClassName()

  • getUrl() → determineUrl()

  • getUsername() → determineUsername()

  • getPassword() → determineUsername()

Note
The get

 메소드는 디프리케이트 되이 않았다. 하지만 이들의 행동이 바뀌었기때문에 당신은 업그레이드할때 수동으로 확인해줘야한다.

DataSource 바인딩 DataSource binding

스프링 부트 1.4 이전에는 자동 설정된 datasource들은 spring.datasourcenamespace. In 1.4, we only bind the common settings to spring.datasource (seeDataSourceProperties) and we have defined new specific namespaces for the four connections pools we support (in that order):
alents:ethods from DataSourceProperties 프링 부트 1.2에선 logging.config 를 써서 로깅 설정파일을 커스터마이즈할 수 있었다. 파일이 존스프링 부트 1.4 이전에는 자동설정된 datasource들은 spring.datasource 네임스페이스에 바인드되었다. 1.4부터 우리는 일반적인 설정만 spring.datasource에 바인드된다(DataSourceProperties를 보자) 그리고 우리가 지원하는 4개의 커넥션풀을 위한 새로운 특정 네임스페이스 정의하였다 (순서대로):
  • org.apache.tomcat.jdbc.pool.DataSource를 위한 spring.datasource.tomcat 

  • com.zaxxer.hikari.HikariDataSource를 위한 spring.datasource.hikari

  • org.apache.commons.dbcp.BasicDataSource를 위한 spring.datasource.dbcp 

  • org.apache.commons.dbcp2.BasicDataSource를 위한 spring.datasource.dbcp2

만일 당신이 사용하는 커넥션풀의 구현물의 특정설정을 사용하고 있다면, 연관된 네임스페이스로 설정을 옮겨줘야한다. 예를 들어, 톰캣의 testOnBorrow 플래그를 사용하고 있다면, spring.datasource.test-on-borrow 에서 spring.datasource.tomcat.test-on-borrow로 옮겨줘야한다.

만일 당신이 사용하는 IDE에서 설정을 도움받았다면, spring.datasource 네임스페이스에 이들을 모두 함께 사용하지않고 커넥션 풀당 어느 설정이 사용가는한지 볼 수 있다. 이는 어느 구현체가 어느 기능을 지원하는지 알아둬야 하는 당신의 삶을 더 쉽게 만들어줄 것이다.

JTA설정 바인딩 JTA settings binding

DataSource binding과 유사하게 Atomikos와 Bitronix 를 위한 특정 JTA제공자 설정 프로퍼티가 spring.jta에 바인드 된다. 이들은 이제 spring.jta.atomikos.properties와 spring.jta.bitronix.properties에 각각 바인드 될 것이다; 이들 엔트리를 위한 메타데이터 또한 크게 향상되었다.

하이버네이트 5 Hibernate 5

하이버네이트 5는 이제 기본 JPA 퍼시스턴스 제공자로서 사용된다. 만일 스프링 부트 1.3에서 업그레이드한다면, 하이버네이트 4.3에서 5.0으로 바꿔줘야한다. 일반적인 업그레이드 방침은 Hibernate migration documentation를 참고하자. 추가적으로 당신은 다음의 것들을 알아둬야한다:

네이밍 전략 Naming Strategy

하이버네이트 5.1이 이전의 NamingStrategy 인터페이스를 지원을 삭제함으로서 SpringNamingStrategy 는 더이상 사용되지 않는다. 새로운 SpringPhysicalNamingStrategy 가 이제 자동설정되어 하이버네이트의 기본 ImplicitNamingStrategy와 함께 사용된다. 이는 스프링부트 1.3의 기본설정과 매우 유사하다 (동일하진않다). 하지만 당신은 업그레이드시 데이터베이스 스키마가 올바른지 확인해주어야 할것이다.

만일 당신이 업그레이드 전 이미 하이버네이트 5를 사용중이라면, 아마 하이버네이트5의 기본설정을 사용하고 있을 것이다. 업그레이드 후에 이를 되돌리길 원하면 당신의 설정에 이 프로퍼티를 설정하면 된다:

spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

제네레이터 매핑 Generator mappings

업그레이드의 고통을 최소화하기 위해, 우리는 하이버네이트5의 hibernate.id.new_generator_mappings을 false를로 설정해두었다. 하이버네이트 팀은 보통 이 설정을 권장하지않는다. 따라서 당신이 제네레이터 변경을 따르려면 당신의 application.properties 파일에 hibernate.id.new_generator_mappings을 true로 설정하면 된다.

하이버네이트 4.3으로 다운그레이드 Downgrading to Hibernate 4.3

하이버네이트 5.0으로 업그레이드하는데 문제가 있다면, pom.xml파일의 hibernate.version 프로퍼티를 오버라이딩함으로서 예전 버젼의 하이버네이트로 다운그레이드 할 수 있다. 

<properties>
    <hibernate.version>4.3.11.Final</hibernate.version>
</properties>

또는 그레들을 사용한다면 hibernate.version 프로퍼티를 다음과 같이 오버라이딩하면 된다:

ext['hibernate.version'] = '4.3.11.Final'
Note

하이버네이트 4.3 은 스프링부터 1.4에서 지원하지 않는다 업그레이드를 방해하는 버그가 있다면  이슈를 제기하자.


@EntityScan

@org.springframework.boot.orm.jpa.EntityScan 어노테이션은 디프리케이트 되어 @org.springframework.boot.autoconfigure.domain.EntityScan 로 변경해주거나 외부 설정을 해주어야한다.

예를 들어 만일 다음의 설정을 가지고 있다면:

import org.springframework.boot.autoconfigure.SpringApplication;
import org.springframework.boot.orm.jpa.EntityScan;

@SpringBootApplication
@EntityScan(basePackageClasses=Customer.class)
public class MyApplication {

    // ....

}

만일 자동설정된 LocalContainerEntityManagerFactoryBean을 사용중이라면 다음과 같이 바꿔준다:

import org.springframework.boot.autoconfigure.SpringApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;

@SpringBootApplication
@EntityScan(basePackageClasses=Customer.class)
public class MyApplication {

    // ....

}

또는 스스로 LocalContainerEntityManagerFactoryBean 을 설정중이라면, @EntityScan 어노테이션을 통째로 버리고 LocalContainerEntityManagerFactoryBean.setPackagesToScan(…​) 를 호출하거나 또는 EntityManagerFactoryBuilder packages(…​) 메소드를 사용해야한다:

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
            EntityManagerFactoryBuilder builder) {
    return builder
        .dataSource(...)
        .properties(...)
        .packages(Customer.class)
        .build();
}

테스트 유틸리티와 클래스들 Test utilities and classes

스프링 부트 1.4는 org.springframework.boot.test 패키지를 완전히 재구성된 새로운 spring-boot-test 모듈을 추가하였다. 스프링 부트 1.3 어플리케이션에서 업그레이드할 때, 예전 패키지들의 디프리케이트된 클래스들을 새 구조의 동일한 클래스로 바꿔주어야한다. 리눅스 또는 OSX를 쓰고있다면 다음의 커맨드를 사용해서 코드를 마이그레잇할 수 있다:

find . -type f -name '*.java' -exec sed -i '' \
-e s/org.springframework.boot.test.ConfigFileApplicationContextInitializer/org.springframework.boot.test.context.ConfigFileApplicationContextInitializer/g \
-e s/org.springframework.boot.test.EnvironmentTestUtils/org.springframework.boot.test.util.EnvironmentTestUtils/g \
-e s/org.springframework.boot.test.OutputCapture/org.springframework.boot.test.rule.OutputCapture/g \
-e s/org.springframework.boot.test.SpringApplicationContextLoader/org.springframework.boot.test.context.SpringApplicationContextLoader/g \
-e s/org.springframework.boot.test.SpringBootMockServletContext/org.springframework.boot.test.mock.web.SpringBootMockServletContext/g \
-e s/org.springframework.boot.test.TestRestTemplate/org.springframework.boot.test.web.client.TestRestTemplate/g \
{} \;

추가적으로, 스프링 부트 1.4는 스프링부트 테스트를 돌릴 수 있는 다양한 방법들을 더 합리적이고 간단하게 하려는 시도를 했다. 당신의 다음의 기존 코드를 새로운 @SpringBootTest 어노테이션을 사용하도록 바꿀수 있다:

  • 기존 @SpringApplicationConfiguration(classes=MyConfig.class) 를 대체하는 새로운 @SpringBootTest(classes=MyConfig.class)

  • 기존 @ContextConfiguration(classes=MyConfig.class, loader=SpringApplicationContextLoader.class)를 대체하는 새로운 @SpringBootTest(classes=MyConfig.class)

  • 기존 @ContextConfiguration(classes=MyConfig.class, loader=SpringApplicationContextLoader.class) 를 대체하는 새로운 @SpringBootTest(classes=MyConfig.class)

  • 기존 @IntegrationTest 를 대체하는 새로운 @SpringBootTest(webEnvironment=WebEnvironment.NONE)

  • 기존 @IntegrationTest와 @WebAppConfiguration 를 대체하는 새로운 @SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT) (또는 RANDOM_PORT)

  • 기존 @WebIntegrationTest to@SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT) (or RANDOM_PORT)

마이그레션 테스트 진행간에 당신은 또한 기존 @RunWith(SpringJUnit4ClassRunner.class)

선언문들을  스프링 4.3의 더 가독성이 좋은 @RunWith(SpringRunner.class).로 대체할 수 있다.

@SpringBootTest 어노테이션에 대한 더 자세한 정보는 다음의 링크를 참고하세요 updated documentation.

TestRestTemplate

TestRestTemplate 클래스는 더이상 직접적으로 RestTemplate 에서 extends되지 않는다. (비록 여전히 같은 메소드를 제공하긴하지만). 이로서 TestRestTemplate 는 의도치않게 주입(accidentally injected)되는 일 없이 하나의 빈 Bean으로서 설정하는게 가능해졌다.  RestTemplate 안에 실제 접근해야할 필요가 있다면 getRestTemplate() 메소드를 사용하자.


메이븐 Spring-boot.version 프로퍼티 Maven spring-boot.version property

The spring-boot.version property has been removed from the spring-boot-dependenciespom. See issue 5104 for details.

Integration Starter

spring-boot-starter-integration 은 일반적인 Spring Integration 어플리케이션에서 필요하지않은 4가지 모듈을 제거함으로서 간소화하였다.  제거된 4개의 모듈은 다음과 같다:

  • spring-integration-file

  • spring-integration-http

  • spring-integration-ip

  • spring-integration-stream

당신의 어플리케이션이 저 4개의 모듈중 하나라도 사용한다면 pom이나 build.gradle에 명시적 의존성을 추가해줘야할 것이다.

추가적으로,  spring-integration-java-dsl 과 spring-integration-jmx 은 이제 스타터에 추가되었다. DSL을 사용하는것은 당신의 어플리케이션의 Spring Intergation을 설정할때 권장되는 되는 방식이다.


Spring Batch Starter

spring-boot-starter-batch starter 는 더이상 embedded 데이터베이스에 의존성을 갖지않는다. 당신이 기존의 방식대로 사용하고 싶다면 당신이 원하는 데이터베이스 (드라이버)를 추가해줘야한다. 예를 들면:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
    <groupId>org.hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <scope>runtime</scope>
</dependency>

이미 다른 드라이버를 설정하여 hsqldb 를 exclusion해두었다면 이젠 exclusion을 지워버려도 된다.

Downgrading Tomcat

톰켓 8.5.4의 tomcat-juli 모듈이 이제 tomcat-embedded의 일부로 패키지 되었다.  수동으로 예전 버전의 톰켓으로 다운그레이드했었다면 이제 tomcat-juli 모듈을 추가해주어야할것이다. 자세한 방법은 다음의 문서를 참고하자 how-to documentation section.

Dispatch Options Request

spring.mvc.dispatch-options-request 의 기본 프로퍼티가  false 에서 스프링 프레임워크의 선호되는 값인 true 로 바뀌었다. 

 FrameworkServlet.doService의  OPTIONS 리퀘스트를 사용하지 않으려면 명시적으로 spring.mvc.dispatch-options-request 를 false.로 바꿔주어야한다.

Forced character encoding

캐릭터 인코딩 강제하기(forced) 이제 요청request에만 적용된다. (응답response는 아님). 요청request과 응답response 둘다 강제하려면 spring.http.encoding.force 를 true로 설정해주어야한다.

Multipart support

multipart 프로퍼티는 multipart에서 spring.http.multipart 로 바뀌었다.

Server header

 Server HTTP 응답헤더 response header 는 이제 server.server-header 프로퍼티를 설정해야지만 설정이 가능하다.

@ConfigurationProperties default bean names

When a @ConfigurationProperties bean is registered via@EnableConfigurationProperties(SomeBean.class), we used to generate a bean name of the form <prefix>.CONFIGURATION_PROPERTIES. As of Spring Boot 1.4, we have changed that pattern to avoid name clashes if two beans use the same prefix.

The new conventional name is <prefix>-<fqn>, where <prefix> is the environment key prefix specified in the @ConfigurationProperties annotation and <fqn> the fully qualified name of the bean. If the annotation does not provide any prefix, only the fully qualified name of the bean is used.

Jetty JNDI support

spring-boot-starter-jetty "스타터Starter"는 더이상 org.eclipse.jetty:jetty-jndi를 포함하지않는다. JNDI를 제티와 같이 사용중이라면 이제 스스로 이 의존성을 직접 추가해줘야만 한다.

Guava caches

구아바 캐시Guava cache 지원을 사용중인 개발자는 Caffeine으로 이주할것을 권장한다.

Remote Shell

The CRaSH properties have moved from the shell. namespace to the management.shell.namespace. Also, the authentication type should now be defined viamanagement.shell.auth.type.

Spring Session auto-configuration improvements

Spring Boot supports more backend stores for Spring Session: alongside Redis, JDBC, MongoDB, Hazelcast and in memory concurrent hash maps are also supported. A newspring.session.store-type mandatory property has been introduced to select the store Spring Session should be using.

Launch script identity

When the launch script is determining the application’s default identity, the canonical name of the directory containing the jar will now be used. Previously, if the directory containing the jar was a symlink, the name of the symlink was used. If you require more control over the application’s identity, the APP_NAME environment variable should be used.

MongoDB 3

The default version of Mongo’s Java Driver is now 3.2.2 (from 2.14.2) and spring-boot-starter-data-mongodb has been updated to use the new, preferred mongodb-driver artifact.

The auto-configuration for Embedded MongoDB has also been updated to use 3.2.2 as its default version.

Thymeleaf 3

기본값으로 스프링 부트는 타임리프 2.1을 사용하지만 이제 타임리프3와도 호환된다. 자세한 내용은 업데이트된 문서 를 찾아보자.

Executable jar layout

실행가능한 jars (executable jars)의 레이아웃이 변경되었다. 스프링부트의 메이븐, 그래들 또는 앤트지원을 통해 빌드한다면 이 변화는 영향을 미치지 않을 것이다. 당신 스스로의 실행가능한 아카이브를 통해서 빌드한다면 이제 어플리케이션이 lib이 아니라 BOOT-INF/lib 에 패키지 된다는 것을 명심하라. 어플리케이션의 클래스들은 이제 jar의 루트가 아닌  BOOT-INF/classes 에 패키지 될것이다.

Integration tests with the maven-failsafe-plugin

As of Failsafe 2.19target/classes is no longer on the classpath and the project’s built jar is used instead. The plugin won’t be able to find your classes due to the change in the executable jar layout. There are two ways to work around this issue:

  1. Downgrade to 2.18.1 so that you use target/classes instead

  2. Configure the spring-boot-maven-plugin to use a classifier for the repackage goal. That way, the original jar will be available and used by the plugin. For example

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <classifier>exec</classifier>
    </configuration>
</plugin>
Note
If you are using Spring Boot’s dependency management, there is nothing to do as you’ll use 2.18.1 by default.
Tip
Watch SUREFIRE-1198 for updates on this issue.

HornetQ

HornetQ 지원은 디프리케이트 되었다. HornetQ 사용자들은 Artemis로 이주할것을 권장한다.

New and Noteworthy

Tip
Check the configuration changelog for a complete overview of the changes in configuration.

Spring Framework 4.3

Spring Boot 1.4 builds on and requires Spring Framework 4.3. There are a number of nice refinements in Spring Framework 4.3 including new Spring MVC @RequestMappingannotations. Refer to the Spring Framework reference documentation for details.

Note that the test framework in Spring Framework 4.3 requires JUnit 4.12. See SPR-13275for further details.

Third-party library upgrades

A number of third party libraries have been upgraded to their latest version. Updates include Jetty 9.3, Tomcat 8.5, Jersey 2.23, Hibernate 5.0, Jackson 2.7, Solr 5.5, Spring Data Hopper, Spring Session 1.2, Hazelcast 3.6, Artemis 1.3, Ehcache 3.1, Elasticsearch 2.3, Spring REST Docs 1.1, Spring AMQP 1.6 & Spring Integration 4.3.

Several Maven plugins were also upgraded.

Couchbase support

Full auto-configuration support is now provided for Couchbase. You can easily access aBucket and Cluster bean by adding the spring-boot-starter-data-couchbase "Starter" and providing a little configuration:

spring.couchbase.bootstrap-hosts=my-host-1,192.168.1.123
spring.couchbase.bucket.name=my-bucket
spring.couchbase.bucket.password=secret

It’s also possible to use Couchbase as a backing store for a Spring Data Repository or as aCacheManager. Refer to the updated documentation for details.

Neo4J Support

Auto-configuration support is now provided for Neo4J. You can connect to a remote server or run an embedded Neo4J server. You can also use Neo4J to back a Spring DataRepository, for example:

public interface CityRepository extends GraphRepository<City> {

    Page<City> findAll(Pageable pageable);

    City findByNameAndCountry(String name, String country);

}

Full details are provided in the Neo4J section of the reference documentation.

Redis Spring Data repositories

Redis can now be used to back Spring Data repositories. See the Spring Data Redisdocumentation for more details.

Narayana transaction manager support

Auto-configuration support is now included for the Narayana transaction manager. You can choose between Narayana, Bitronix or Atomkos if you need JTA support. See the updated reference guide for details.

Caffeine cache support

Auto-configuration is provided for Caffeine v2.2 (a Java 8 rewrite of Guava’s caching support). Existing Guava cache users should consider migrating to Caffeine as Guava cache support will be dropped in a future release.

Elasticsearch Jest support

Spring Boot auto-configures a JestClient and a dedicated HealthIndicator if Jest is on the classpath. This allows you to use Elasticsearch even when spring-data-elasticsearch isn’t on the classpath.

Analysis of startup failures

Spring Boot will now perform analysis of common startup failures and provide useful diagnostic information rather than simply logging an exception and its stack trace. For example, a startup failure due to the embedded servlet container’s port being in use looked like this in earlier versions of Spring Boot:

2016-02-16 17:46:14.334 ERROR 24753 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.RuntimeException: java.net.BindException: Address already in use
    at io.undertow.Undertow.start(Undertow.java:181) ~[undertow-core-1.3.14.Final.jar:1.3.14.Final]
    at org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainer.start(UndertowEmbeddedServletContainer.java:121) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:293) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at sample.undertow.SampleUndertowApplication.main(SampleUndertowApplication.java:26) [classes/:na]
Caused by: java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_60]
    at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_60]
    at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_60]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_60]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_60]
    at org.xnio.nio.NioXnioWorker.createTcpConnectionServer(NioXnioWorker.java:190) ~[xnio-nio-3.3.4.Final.jar:3.3.4.Final]
    at org.xnio.XnioWorker.createStreamConnectionServer(XnioWorker.java:243) ~[xnio-api-3.3.4.Final.jar:3.3.4.Final]
    at io.undertow.Undertow.start(Undertow.java:137) ~[undertow-core-1.3.14.Final.jar:1.3.14.Final]
    ... 11 common frames omitted

In 1.4, it will look like this:

2016-02-16 17:44:49.179 ERROR 24745 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Embedded servlet container failed to start. Port 8080 was already in use.

Action:

Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

If you still want to see the stacktrace of the underlying cause, enable debug logging fororg.springframework.boot.diagnostics.LoggingFailureAnalysisReporter.

Image Banners

You can now use image files to render ASCII art banners. Drop a banner.gifbanner.jpg orbanner.png file into src/main/resources to have it automatically converted to ASCII. You can use the banner.image.width and banner.image.height properties to tweak the size, or usebanner.image.invert to invert the colors.

banner image

RestTemplate builder

A new RestTemplateBuilder can be used to easily create a RestTemplate with sensible defaults. By default, the built RestTemplate will attempt to use the most suitableClientHttpRequestFactory available on the classpath and will be aware of theMessageConverter instances to use (including Jackson). The builder includes a number of useful methods that can be used to quickly configure a RestTemplate. For example, to add BASIC auth support you can use:

@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
    return builder.basicAuthorization("user", "secret").build();
}

The auto-configured TestRestTemplate now uses the RestTemplateBuilder as well.

JSON Components

A new @JsonComponent annotation is now provided for custom Jackson JsonSerializer and/orJsonDeserializer registration. This can be a useful way to decouple JSON serialization logic:

@JsonComponent
public class Example {

    public static class Serializer extends JsonSerializer<SomeObject> {
        // ...
    }

    public static class Deserializer extends JsonDeserializer<SomeObject> {
        // ...
    }

}

Additionally, Spring Boot also now provides JsonObjectSerializer and JsonObjectDeserializerbase classes which provide useful alternatives to the standard Jackson versions when serializing objects. See the updated documentation for details.

Convention based error pages

Custom error pages for a given status code can now be created by following a convention based approach. Create a static HTML file in /public/error or add a template to/templates/error using the status code as the filename. For example, to register a custom 404 file you could add src/main/resource/public/error/404.html. See the updated reference documentation for details.

Unified @EntityScan annotation

org.springframework.boot.autoconfigure.domain.EntityScan can now be used to specify the packages to use for JPA, Neo4J, MongoDB, Cassandra and Couchbase. As a result, the JPA-specific org.springframework.boot.orm.jpa.EntityScan is now deprecated.

ErrorPageRegistry

New ErrorPageRegistry and ErrorPageRegistrar interfaces allow error pages to be registered in a consistent way regardless of the use of an embedded servlet container. TheErrorPageFilter class has been updated to that it is now a ErrorPageRegistry and not a fakeConfigurableEmbeddedServletContainer.

PrincipalExtractor

The PrincipalExtractor interface can now be used if you need to extract the OAuth2Principal using custom logic.

Test improvements

Spring Boot 1.4 includes a major overhaul of testing support. Test classes and utilities are now provided in dedicated spring-boot-test and spring-boot-test-autoconfigure jars (although most users will continue to pick them up via the spring-boot-starter-test"Starter"). We’ve added AssertJ, JSONassert and JsonPath dependencies to the test starter.

@SpringBootTest

With Spring Boot 1.3 there were multiple ways of writing a Spring Boot test. You could use@SpringApplicationConfiguration@ContextConfiguration with theSpringApplicationContextLoader@IntegrationTest or @WebIntegrationTest. With Spring Boot 1.4, a single @SpringBootTest annotation replaces all of those.

Use @SpringBootTest in combination with @RunWith(SpringRunner.class) and set thewebEnvironment attribute depending on the type of test you want to write.

A classic integration test, with a mocked servlet environment:

@RunWith(SpringRunner.class)
@SpringBootTest
public class MyTest {

    // ...

}

A web integration test, running a live server listening on a defined port:

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvionment.DEFINED_PORT)
public class MyTest {

    // ...

}

A web integration test, running a live server listening on a random port:

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvionment.RANDOM_PORT)
public class MyTest {

	@LocalServerPort
	private int actualPort;

	// ...

}

See the updated reference documentation for details.

Auto-detection of test configuration

Test configuration can now be automatically detected for most tests. If you follow the Spring Boot recommended conventions for structuring your code the @SpringBootApplication class will be loaded when no explicit configuration is defined. If you need to load a different@Configuration class you can either include it as a nested inner-class in your test, or use theclasses attribute of @SpringBootTest.

See Detecting test configuration for details.

Mocking and spying beans

It’s quite common to want to replace a single bean in your ApplicationContext with a mock for testing purposes. With Spring Boot 1.4 this now as easy as annotating a field in your test with @MockBean:

@RunWith(SpringRunner.class)
@SpringBootTest
public class MyTest {

    @MockBean
    private RemoteService remoteService;

    @Autowired
    private Reverser reverser;

    @Test
    public void exampleTest() {
        // RemoteService has been injected into the reverser bean
        given(this.remoteService.someCall()).willReturn("mock");
        String reverse = reverser.reverseSomeCall();
        assertThat(reverse).isEqualTo("kcom");
    }

}

You can also use @SpyBean if you want to spy on an existing bean rather than using a full mock.

See the mocking section of the reference documentation for more details.

Auto-configured tests

Full application auto-configuration is sometime overkill for tests, you often only want to auto-configure a specific "slice" of your application. Spring Boot 1.4 introduces a number of specialized test annotations that can be used for testing specific parts of your application:

  • @JsonTest - For testing JSON marshalling and unmarshalling.

  • @WebMvcTest - For testing Spring MVC @Controllers using MockMVC.

  • @RestClientTest - For testing RestTemplate calls.

  • @DataJpaTest - For testing Spring Data JPA elements

Many of the annotations provide additional auto-configuration that’s specific to testing. For example, if you use @WebMvcTest you can @Autowire a fully configured MockMvc instance.

See the reference documentation for details.

JSON AssertJ assertions

New JacksonTesterGsonTester and BasicJsonTester classes can be used in combination with AssertJ to test JSON marshalling and unmarshalling. Testers can be used with the@JsonTest annotation or directly on a test class:

@RunWith(SpringRunner.class)
@JsonTest
public class MyJsonTests {

    private JacksonTester<VehicleDetails> json;

    @Test
    public void testSerialize() throws Exception {
        VehicleDetails details = new VehicleDetails("Honda", "Civic");
        assertThat(this.json.write(details)).isEqualToJson("expected.json");
        assertThat(this.json.write(details)).hasJsonPathStringValue("@.make");
    }

}

See the JSON section of the reference documentation or the Javadocs for details.

@RestClientTest

The @RestClientTest annotation can be used if you want to test REST clients. By default it will auto-configure Jackson and GSON support, configure a RestTemplateBuilder and add support for MockRestServiceServer.

Auto-configuration for Spring REST Docs

Combined with the support for auto-configuring MockMvc described above, auto-configuration for Spring REST Docs has been introduced. REST Docs can be enabled using the new @AutoConfigureRestDocs annotation. This will result in the MockMvc instance being automatically configured to use REST Docs and also removes the need to use REST Docs' JUnit rule. Please see the relevant section of the reference documentation for further details.

Test utilities

spring-boot-starter-test now brings the AssertJ assertions library.

Test utilities from the org.springframework.boot.test package have been moved to a spring-boot-test dedicated artifact.

Actuator info endpoint improvements

You can now use the InfoContributor interface to register beans that expose information to the /info actuator endpoint. Out of the box support is provided for:

  • Full or partial Git information generated from the git-commit-id-plugin Maven or gradle-git-properties Gradle plugin (set management.info.git.mode=full to expose full details)

  • Build information generated from the Spring Boot Maven or Gradle plugin.

  • Custom information from the Environment (any property starting info.*)

Details are documented in the "Application information" section of the reference docs.

MetricsFilter improvements

The MetricsFilter can now submit metrics in both the classic "merged" form, or grouped per HTTP method. Use endpoints.metrics.filter properties to change the configuration:

endpoints.metrics.filter.gauge-submissions=grouped
endpoints.metrics.filter.counter-submissions=grouped,merged

Spring Session JDBC Initializer

If Spring Session is configured to use the JDBC store, the schema is now created automatically on startup.

Secured connection for Artemis/HornetQ

Spring Boot now allows to connect against a secured Artemis/HornetQ broker.

Miscellaneous

  • server.jetty.acceptors and server.jetty.selectors properties have been added to configure the number of Jetty acceptors and selectors.

  • server.max-http-header-size and server.max-http-post-size can be used to constrain maximum sizes for HTTP headers and HTTP POSTs. Settings work on Tomcat, Jetty and Undertow.

  • The minimum number of spare threads for Tomcat can now be configured usingserver.tomcat.min-spare-threads

  • Profile negation in now supported in application.yml files. Use the familiar ! prefix inspring.profiles values

  • The actuator exposes a new headdump endpoint that returns a GZip compressed hprofheap dump file

  • Spring Mobile is now auto-configured for all supported template engines

  • The Spring Boot maven plugin allows to bundle system scoped artifacts using the newincludeSystemScope attribute

  • spring.mvc.log-resolved-exception enables the automatic logging of a warning when an exception is resolved by a HandlerExceptionResolver

  • spring.data.cassandra.schema-action you be used to customize the schema action to take on startup

  • Spring Boot’s fat jar format should now consume much less memory

  • Locale to Charset mapping is now supported via the spring.http.encoding.mapping.<locale>=<charset> property

Spring Data "Ingalls" release train support

Spring Boot 1.4 GA ships with the Spring Data "Hopper" release out of the box. Users that would like to try the "Ingalls" release train (available in milestone one at the time of writing) can do so by just setting the spring-data-releasetrain.version property to Ingalls-M1 and declaring the Spring milestone repository.

Depending on what modules of Spring Data you use, you might have to upgrade a couple of transitive dependencies, too:

  • Spring Data REST users will have to upgrade to Spring HATEOAS 0.21 (set spring-hateoas.version to 0.21.0.RELEASE)

  • Spring Data Redis users using Jedis as driver will have to upgrade to 2.9 (setjedis.version to 2.9.0)

Deprecations in Spring Boot 1.4

  • Velocity support has been deprecated since support has been deprecated as of Spring Framework 4.3.

  • Some constructors in UndertowEmbeddedServletContainer have been deprecated (most uses should be unaffected).

  • The locations and merge attributes of the @ConfigurationProperties annotation have been deprecated in favor of directly configuring the Environment.

  • The protected SpringApplication.printBanner method should no longer be used to print a custom banner. Use the Banner interface instead.

  • The protected InfoEndpoint.getAdditionalInfo method has been deprecated in favor of the InfoContributor interface.

  • org.springframework.boot.autoconfigure.test.ImportAutoConfiguration has been moved toorg.springframework.boot.autoconfigure.

  • All classes in the org.springframework.boot.test package have been deprecated. See the "upgrading" notes above for details.

  • PropertiesConfigurationFactory.setProperties(Properties) is deprecated in favor of usingPropertySources.

  • Several classes in the org.springframework.boot.context.embedded package have been deprecated and relocated to org.springframework.boot.web.servlet.

  • All classes in the org.springframework.boot.context.web package have been deprecated and relocated.

  • The spring-boot-starter-ws "Starter" has been renamed to spring-boot-starter-web-services.

  • The spring-boot-starter-redis "Starter" has been renamed to spring-boot-starter-data-redis.

  • The spring-boot-starter-hornetq starter and auto-configuration has been deprecated in favour of using spring-boot-starter-artemis

  • management.security.role has been deprecated in favour of management.security.roles

  • The @org.springframework.boot.orm.jpa.EntityScan annotation has been deprecated in favor of @org.springframework.boot.autoconfigure.domain.EntityScan or explicit configuration.

  • TomcatEmbeddedServletContainerFactory.getValves() has been deprecated in favor ofgetContextValves().

  • org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter has been deprecated in favor of org.springframework.boot.system.EmbeddedServerPortFileWriter

  • org.springframework.boot.actuate.system.ApplicationPidFileWriter has been deprecated in favor of org.springframework.boot.system.ApplicationPidFileWriter

Property Renames

  • spring.jackson.serialization-inclusion should be replaced with spring.jackson.default-property-inclusion.

  • spring.activemq.pooled should be replaced with spring.activemq.pool.enabled.

  • spring.jpa.hibernate.naming-strategy should be replaced withspring.jpa.hibernate.naming.strategy.

  • server.tomcat.max-http-header-size should be replaced with server.max-http-header-size.



반응형

반응형

자바에서 요일(day of week)을 구하는 간단한 방법

(원문:http://www.leveluplunch.com/java/examples/get-day-of-week/)


Java Calendar

Calendar cal = Calendar.getInstance();

cal.set(Calendar.MONTH, Calendar.APRIL);

cal.set(Calendar.DAY_OF_MONTH, 4);

cal.set(Calendar.YEAR, 2016);

int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);

assertEquals(Calendar.FRIDAY, dayOfWeek);


Java 8

LocalDate date = LocalDate.of(2016, Month.APRIL, 4);

DayOfWeek dayOfWeek = date.getDayOfWeek();

assertEquals(DayOfWeek.FRIDAY, dayOfWeek);

또는 

int dayOfWeek2 = dayOfWeek.get(ChronoField.DAY_OF_WEEK);

assertEquals(DayOfWeek.FRIDAY.getValue(), dayOfWeek2);

또는    

LocalDateTime localDateTime = LocalDateTime.of(2016, Month.APRIL, 4, 5, 4);

DayOfWeek dayOfWeek3 = localDateTime.getDayOfWeek();

assertEquals(DayOfWeek.FRIDAY, dayOfWeek3);


Joda Time

DateTime dateTime = new DateTime(2016, 4, 4, 0, 0);

int dayOfWeek = dateTime.getDayOfWeek();

assertEquals(DateTimeConstants.FRIDAY, dayOfWeek);


Old JDK

int day = 2;
DateFormatSymbols dfs = DateFormatSymbols.getInstance(Locale.ENGLISH);
System.out.println(dfs.getWeekdays()[day % 7 + 1]);




반응형

+ Recent posts