question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

spring-boot generator can not handle multi-profile configuration

See original GitHub issue

Description

I have a Spring Boot application.yml file with following format :

spring:
  profiles:
    active: default
---

spring:
  profiles: default
hono:
  downstream:
    host: localhost
    port: 5672
    name: hono-server
  maxInstances: 0
  singleTenant: false
  server:
    bindaddress: 127.0.0.1
    port: 5672

Using the plugin I have the following error :

[ERROR] Failed to execute goal io.fabric8:fabric8-maven-plugin:3.2.14:resource (default) on project hono-app: Execution default of goal io.fabric8:fabric8-maven-plugin:3.2.14:resource failed: Cannot extract generator: expected a single document in the stream
[ERROR] in 'reader', line 1, column 1:
[ERROR] spring:
[ERROR] ^
[ERROR] but found another document
[ERROR] in 'reader', line 4, column 1:
[ERROR] ---
[ERROR] ^
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:fabric8-maven-plugin:3.2.14:resource (default) on project hono-app: Execution default of goal io.fabric8:fabric8-maven-plugin:3.2.14:resource failed: Cannot extract generator: expected a single document in the stream
 in 'reader', line 1, column 1:
    spring:
    ^
but found another document
 in 'reader', line 4, column 1:
    ---
    ^

	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:352)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:197)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal io.fabric8:fabric8-maven-plugin:3.2.14:resource failed: Cannot extract generator: expected a single document in the stream
 in 'reader', line 1, column 1:
    spring:
    ^
but found another document
 in 'reader', line 4, column 1:
    ---
    ^

	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 24 more
Caused by: java.lang.IllegalArgumentException: Cannot extract generator: expected a single document in the stream
 in 'reader', line 1, column 1:
    spring:
    ^
but found another document
 in 'reader', line 4, column 1:
    ---
    ^

	at io.fabric8.maven.plugin.mojo.build.ResourceMojo$3.customizeConfig(ResourceMojo.java:620)
	at io.fabric8.maven.docker.config.ConfigHelper.resolveImages(ConfigHelper.java:51)
	at io.fabric8.maven.plugin.mojo.build.ResourceMojo.getResolvedImages(ResourceMojo.java:593)
	at io.fabric8.maven.plugin.mojo.build.ResourceMojo.executeInternal(ResourceMojo.java:225)
	at io.fabric8.maven.plugin.mojo.AbstractFabric8Mojo.execute(AbstractFabric8Mojo.java:74)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	... 25 more
Caused by: expected a single document in the stream
 in 'reader', line 1, column 1:
    spring:
    ^
but found another document
 in 'reader', line 4, column 1:
    ---
    ^

	at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:110)
	at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:120)
	at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:450)
	at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:444)
	at io.fabric8.maven.core.util.SpringBootUtil.getPropertiesFromYamlResource(SpringBootUtil.java:97)
	at io.fabric8.maven.core.util.SpringBootUtil.getSpringBootApplicationProperties(SpringBootUtil.java:51)
	at io.fabric8.maven.generator.springboot.SpringBootGenerator.extractPorts(SpringBootGenerator.java:99)
	at io.fabric8.maven.generator.javaexec.JavaExecGenerator.customize(JavaExecGenerator.java:116)
	at io.fabric8.maven.generator.springboot.SpringBootGenerator.customize(SpringBootGenerator.java:76)
	at io.fabric8.maven.plugin.generator.GeneratorManager.generate(GeneratorManager.java:62)
	at io.fabric8.maven.plugin.mojo.build.ResourceMojo$3.customizeConfig(ResourceMojo.java:618)
	... 30 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

It seems that it’s not able to handle the “—” separator.

Info

  • f-m-p version : 3.2.14
  • Maven version (mvn -v) : 3.3.9

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
anwarchkcommented, Aug 29, 2019
1reaction
tuyenttrancommented, Feb 21, 2017

Can we detect active profiles from system environment or parameter (spring.profiles.active) when parsing YAML file?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How configure spring multiple profiles databases javaconfig
I solved the problem by moving the database configuration classes to load along with the root settings @Override protected Class<?> ...
Read more >
Core Features - Spring
Spring Boot lets you externalize your configuration so that you can work with the same application code in different environments.
Read more >
Unable to change spring run profile - always it starts with dev ...
Looks like from v4.12.0 and newer applications may be affected with stuck-spring-profile-selection which always runs app on dev,swagger (default) ...
Read more >
Top 10 Most Common Spring Framework Mistakes - Toptal
Common Mistake #8: Forgetting About Profiles. A problem often encountered in server development is distinguishing between different configuration types, usually ...
Read more >
Spring Profiles - Baeldung
Spring Boot will automatically load the properties in an application.properties file for all profiles, and the ones in profile-specific .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found