2017-05-31 4 views
2

Ich habe folgenden Inhalt in application.yml:Wie läuft man mit Profil? Nachschlüssel: spring

spring: 
    jpa: 
    generate-ddl: false 
    hibernate: 
     ddl-auto: none 
     dialect: org.hibernate.dialect.SQLServer2012Dialect 
    profiles: 
    active: @[email protected] 
    ... 
    spring: 
    profiles: test 
    datasource: 
    url: jdbc:h2://localhost:1433;database=testdb 
    username: sa 
    password: 

und ich Anwendung wie diese beginnen:

gradle bootRun -Pspring.profiles.active=test 

Ich sehe folgende Fehlermeldung:

:common-classes:compileJava UP-TO-DATE           
:common-classes:processResources UP-TO-DATE  
:common-classes:classes UP-TO-DATE  
:common-classes:jar UP-TO-DATE  
:compileJava UP-TO-DATE               
:processResources UP-TO-DATE  
:classes UP-TO-DATE  
:findMainClass     
:bootRun                  
15:45:12.450 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSet 
15:45:12.452 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSet 
, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/] 
15:45:12.453 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUr 
15:45:12.642 [restartedMain] DEBUG org.springframework.boot.logging.ClasspathLog 
15:45:12.644 [restartedMain] ERROR org.springframework.boot.SpringApplication - 
org.yaml.snakeyaml.parser.ParserException: while parsing MappingNode 
in 'reader', line 70, column 1: 
    spring: 
    ^
Duplicate key: spring 
in 'reader', line 82, column 14: 
    password: 
      ^

     at org.springframework.beans.factory.config.YamlProcessor$StrictMapAppen 
     at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.const 
     at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseCo 
     at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(Base 
     at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructo 
     at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:471) 
     at org.springframework.beans.factory.config.YamlProcessor.process(YamlPr 
     at org.springframework.beans.factory.config.YamlProcessor.process(YamlPr 
     at org.springframework.boot.env.YamlPropertySourceLoader$Processor.proce 
     at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlProper 
     at org.springframework.boot.env.PropertySourcesLoader.load(PropertySourc 
     at org.springframework.boot.context.config.ConfigFileApplicationListener 
     at org.springframework.boot.context.config.ConfigFileApplicationListener 
     at org.springframework.boot.context.config.ConfigFileApplicationListener 
     at org.springframework.boot.context.config.ConfigFileApplicationListener 
     at org.springframework.boot.context.config.ConfigFileApplicationListener 
     at org.springfk.boot.context.config.ConfigFileApplicationListener.onAppl 
     at org.springframework.boot.context.config.ConfigFileApplicationListener 
     at org.springframework.context.event.SimpleApplicationEventMulticaster.i 
     at org.springframework.context.event.SimpleApplicationEventMulticaster.m 
     at org.springframework.context.event.SimpleApplicationEventMulticaster.m 
     at org.springframework.boot.context.event.EventPublishingRunListener.env 
     at org.springframework.boot.SpringApplicationRunListeners.environmentPre 
     at org.springframework.boot.SpringApplication.prepareEnvironment(SpringA 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java 
     at org.springframework.boot.SpringApplication.run(SpringApplication.java 
     at com.finvale.MarketplaceApplication.main(MarketplaceApplication.java:1 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces 
     at java.lang.reflect.Method.invoke(Method.java:498) 
     at org.springframework.boot.devtools.restart.RestartLauncher.run(Restart 

Was habe ich falsch ?

Antwort

2

Sie spring zweimal in Ihrer Konfiguration erklärt haben:

spring: 
    ... 
    spring: 
    profiles: test 

obwohl es nur einmal erklärt werden muss, wie folgt:

spring: 
    ... 
    profiles: test 

Nur spring: entfernen, die vor profiles: geht

Verwandte Themen