用YAML弹簧启动,CORS不起作用

时间:2017-07-07 16:21:55

标签: spring-boot cors yaml

是否可以创建YAML配置来处理CORS?我使用gradle和spring boot ver 1.5.4。 这是我的YML文件,它不起作用:

 endpoints:
  cors:
    allowed-methods: '*'
    allowed-origins: '*'

的build.gradle:

buildscript {
    ext {
       springBootVersion = '1.5.4.RELEASE'
    }
    repositories {
       jcenter()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    jcenter()
}

configurations {
    providedRuntime
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-actuator')
    compile('org.springframework.boot:spring-boot-starter-data-elasticsearch')
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-freemarker')
    compile('org.springframework.boot:spring-boot-starter-mail')
    compile('org.springframework.boot:spring-boot-starter-web')
    runtime('mysql:mysql-connector-java')
    compileOnly('org.projectlombok:lombok')
    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

任何人都知道出了什么问题?提前感谢您的帮助

0 个答案:

没有答案