Spring Boot 2.0.2

This commit is contained in:
Vitaly Takmazov 2018-05-10 09:49:55 +03:00
parent eef3d052fe
commit f28b196898
6 changed files with 24 additions and 16 deletions

View File

@ -1,6 +1,6 @@
buildscript { buildscript {
ext { ext {
springBootVersion = '1.5.6.RELEASE' springBootVersion = '2.0.2.RELEASE'
} }
repositories { repositories {
mavenCentral() mavenCentral()
@ -14,6 +14,14 @@ apply plugin: 'java'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'idea' apply plugin: 'idea'
apply plugin: 'org.springframework.boot' apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
applyMavenExclusions = false
}
version = '0.0.1-SNAPSHOT' version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
@ -33,17 +41,17 @@ dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa') compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.flywaydb:flyway-core') compile('org.flywaydb:flyway-core')
compile('org.springframework.boot:spring-boot-starter-hateoas') compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.0') compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2')
compile('org.springframework.boot:spring-boot-starter-web') compile('org.springframework.boot:spring-boot-starter-web')
compile('io.jsonwebtoken:jjwt:0.7.0') compile('io.jsonwebtoken:jjwt:0.9.0')
compile('org.springframework.boot:spring-boot-starter-security') compile('org.springframework.boot:spring-boot-starter-security')
compile('joda-time:joda-time:2.9.9') compile('joda-time:joda-time:2.9.9')
compileOnly('org.projectlombok:lombok') compileOnly('org.projectlombok:lombok')
runtime('com.h2database:h2') runtime('com.h2database:h2')
testCompile 'io.rest-assured:rest-assured:3.0.2' testCompile 'io.rest-assured:rest-assured:3.1.0'
testCompile 'io.rest-assured:spring-mock-mvc:3.0.2' testCompile 'io.rest-assured:spring-mock-mvc:3.1.0'
testCompile 'org.springframework.security:spring-security-test:4.0.4.RELEASE' testCompile 'org.springframework.security:spring-security-test'
testCompile('org.springframework.boot:spring-boot-starter-test') testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc') testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
testCompile('org.mybatis.spring.boot:mybatis-spring-boot-starter-test:1.3.0') testCompile('org.mybatis.spring.boot:mybatis-spring-boot-starter-test:1.3.2')
} }

Binary file not shown.

View File

@ -1,6 +1,5 @@
#Mon Aug 07 11:04:20 CST 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip

View File

@ -2,10 +2,10 @@ package io.spring.api.security;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration @Configuration
public class CORSConfig extends WebMvcConfigurerAdapter { public class CORSConfig implements WebMvcConfigurer {
@Override @Override
public void addCorsMappings(CorsRegistry registry) { public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**") registry.addMapping("/**")

View File

@ -1,14 +1,15 @@
package io.spring.api.security; package io.spring.api.security;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.security.Http401AuthenticationEntryPoint;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource; import org.springframework.web.cors.CorsConfigurationSource;
@ -40,7 +41,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.csrf().disable() http.csrf().disable()
.cors() .cors()
.and() .and()
.exceptionHandling().authenticationEntryPoint(new Http401AuthenticationEntryPoint("Unauthenticated")) .exceptionHandling().authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))
.and() .and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests() .authorizeRequests()