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 ide not working with nested @ConstructorBinding when not an inner class

See original GitHub issue

Version: Spring IDE 4.5.0.RELEASE

I’m using Spring Boot 2.2.2 I have the following @ConfigurationProperties setup with @ConstructorBinding which works great during runtime but the IDE fails to auto complete. Any ideas?

package test;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;

@ConfigurationProperties(prefix = "someConfig")
public class ConfigProperties {

  @ConstructorBinding
  public ConfigProperties(NestedConfigProperties nested, NestedConfigProperties nested2) {}
}
package test;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;

@ConfigurationProperties
public class NestedConfigProperties {

  @ConstructorBinding
  public NestedConfigProperties(String dude) {}

  public String getBob() {
    return null;
  }

  public void setBob(String dude) {}
}

I would expect to see “dude” as an option. Instead I get an error. image

Oddly enough the IDE seems to like bob in this case even though it doesn’t exist in the configuration metadata.

This is what the configuration metadata looks like:

{
  "groups": [
    {
      "name": "",
      "type": "test.NestedConfigProperties",
      "sourceType": "test.NestedConfigProperties"
    },
    {
      "name": "someConfig",
      "type": "test.ConfigProperties",
      "sourceType": "test.ConfigProperties"
    }
  ],
  "properties": [
    {
      "name": "dude",
      "type": "java.lang.String",
      "sourceType": "test.NestedConfigProperties"
    },
    {
      "name": "someConfig.nested",
      "type": "test.NestedConfigProperties",
      "sourceType": "test.ConfigProperties"
    },
    {
      "name": "someConfig.nested2",
      "type": "test.NestedConfigProperties",
      "sourceType": "test.ConfigProperties"
    }
  ],
  "hints": []
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kdvoldercommented, Mar 17, 2020

Martin suggested we can still merge it in last minute if it is ‘low risk’. So… Okay, I think its low-impact and low-risk. The extra code just handles an extra case (when it sees specific annotation on a type). So its merged now.

1reaction
kdvoldercommented, Mar 17, 2020

This didn’t make it yet into the next release. But the fix is in a branch waiting to be merged right after.

Branch: https://github.com/spring-projects/sts4/tree/gh_404

Read more comments on GitHub >

github_iconTop Results From Across the Web

spring boot binding app properties for nested class
I'm trying to bind app properties to the below class with a nested properties but it's not working as I ...
Read more >
Configuration Metadata - Spring
Nested Properties. The annotation processor automatically considers inner classes as nested properties. Rather than documenting the ip and port ...
Read more >
Configuration Properties With Kotlin | Javarevisited - Medium
How to use @ConstructorBinding in combination with Kotlin data classes ... as Spring is able to bind properties to a list without problems....
Read more >
IntelliJ IDEA 2022.2 (222.3345.118 build) Release Notes
Bug, IDEA-295082, IntelliJ 2022.2 EAP 2 does not support Android Gradle Plugin 7.2.0 ... not working when an IDE is activated not with...
Read more >
spring-projects/spring-boot - Gitter
I've tested that as well and found two issues with it. ... I guess there might be some edge cases so even if...
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