GithubHelp home page GithubHelp logo

egoettelmann / spring-configuration-extensions Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 2.0 338 KB

Generate Spring configuration properties metadata from `@Value` annotations

License: Apache License 2.0

Java 96.42% FreeMarker 3.58%
maven-plugin spring-boot spring-configuration spring-configuration-metadata spring-value-annotations

spring-configuration-extensions's People

Contributors

ciis0 avatar egoettelmann avatar kerwin612 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

ciis0 kerwin612

spring-configuration-extensions's Issues

Issues with booleans without explicit default value

first, thank for this project!

in certain constellations, I am running into problems with boolean values during (html) report generation using the Maven plugin:

In that case then the aggregation seems to store the default value obtained from Java in metadata JSON as a actual boolean and then report generation fails with the error below.

A workaround is to declare default value in application.yml (not .yaml!) or application.properties, then it's stored as string in metadata and FreeMarker is happy.

I am open to look into providing a fix PR. :)

SEVERE: Error executing FreeMarker template
FreeMarker template error:
Can't convert boolean to string automatically, because the "boolean_format" setting was "true,false", which is the legacy deprecated default, and we treat it as if no format was set. This is the default configuration; you should provide the format explicitly for each place where you print a boolean.

----
Tip: Write something like myBool?string('yes', 'no') to specify boolean formatting in place.
----
Tip: If you want "true"/"false" result as you are generating computer-language output (not for direct human consumption), then use "?c", like ${myBool?c}. (If you always generate computer-language output, then it's might be reasonable to set the "boolean_format" setting to "c" instead.)
----
Tip: If you need the same two values on most places, the programmers can set the "boolean_format" setting to something like "yes,no". However, then it will be easy to unwillingly format booleans like that.
----

----
FTL stack trace ("~" means nesting-related):
	- Failed at: ${(property.defaultValue?j_string)!}  [in template "default.ftl" at line 113, column 35]
----

Java stack trace (for programmers):
----
freemarker.core._MiscTemplateException: [... Exception message was already printed; see it above ...]
	[...]
	at com.github.egoettelmann.spring.configuration.extensions.aggregator.maven.components.reporting.writers.HtmlReportWriter.write(HtmlReportWriter.java:60)
	at com.github.egoettelmann.spring.configuration.extensions.aggregator.maven.components.reporting.DefaultReportingService.save(DefaultReportingService.java:74)
	at com.github.egoettelmann.spring.configuration.extensions.aggregator.maven.ReporterMojo.execute(ReporterMojo.java:88)
[...]

javax.annotation.processing.FilerException: Attempt to reopen a file for path /META-INF/additional-spring-configuration-metadata.json

[WARNING] Unable to merge additional metadata
[WARNING] javax.annotation.processing.FilerException: Attempt to reopen a file for path /.cache/act/f8cc9a9e9eafffbb/hostexecutor/target/classes/META-INF/additional-spring-configuration-metadata.json
  	at jdk.compiler/com.sun.tools.javac.processing.JavacFiler.checkFileReopening(JavacFiler.java:766)
  	at jdk.compiler/com.sun.tools.javac.processing.JavacFiler.getResource(JavacFiler.java:598)
  	at org.springframework.boot.configurationprocessor.MetadataStore.getAdditionalMetadataStream(MetadataStore.java:104)
  	at org.springframework.boot.configurationprocessor.MetadataStore.readAdditionalMetadata(MetadataStore.java:76)
  	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.mergeAdditionalMetadata(ConfigurationMetadataAnnotationProcessor.java:350)
  	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.writeMetadata(ConfigurationMetadataAnnotationProcessor.java:339)
  	at org.springframework.boot.configurationprocessor.ConfigurationMetadataAnnotationProcessor.process(ConfigurationMetadataAnnotationProcessor.java:189)
  	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:1023)
  	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.runContributingProcs(JavacProcessingEnvironment.java:859)
  	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1265)
  	at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1404)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1234)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:916)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
  	at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:136)
  	at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:183)
  	at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1140)
  	at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:193)
  	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
  	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:342)
  	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:330)
  	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
  	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:175)
  	at org.apache.maven.lifecycle.internal.MojoExecutor.access$000(MojoExecutor.java:76)
  	at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:163)
  	at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute(DefaultMojosExecutionStrategy.java:39)
  	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:160)
  	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:105)
  	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:73)
  	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:53)
  	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:118)
  	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:261)
  	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:173)
  	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:101)
  	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:827)
  	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:272)
  	at org.apache.maven.cli.MavenCli.main(MavenCli.java:195)
  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
  	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
  	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
  	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
  	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

It is recommended to add some tags to the repo

It is recommended to add some tags to the repo, similar to: maven-plugin spring-boot spring-configuration-metadata etc.

This is a very nice library that solves the problem I'm trying to solve, but I had a hard time finding it. Before I found this library, I tried to search it on google/github with some keywords, but the result was not able to locate this library, so I suggest adding some tags to make it easier for people who need it to find it faster.

NPE

source code:
image
spring-configuration-metadata.json:
image
debugger:
image
image

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`)

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`)  at [Source: (sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream); line: 1450, column: 23] (through reference chain: com.github.egoettelmann.spring.configuration.extensions.aggregator.maven.core.model.PropertyMetadata$Wrapper["properties"]->java.util.ArrayList[3]->com.github.egoettelmann.spring.configuration.extensions.aggregator.maven.core.model.PropertyMetadata["defaultValue"])

image
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.