I am aware of the various JMix and Spring Properties classes and how to inject them. But I am wondering how I could make my own Properties class. I’ve attempted on my own by copying an existing class, without success. I figure I am missing some nuance so any advice would be appreciated.
This is the class I attempted with, for reference:
package com.company.deiproductconfig2.core;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
import org.springframework.boot.context.properties.bind.DefaultValue;
@ConfigurationProperties(prefix = "aspen")
@ConstructorBinding
public class AspenProperties {
String buildDate;
public AspenProperties(
@DefaultValue("-UNKNOWN BUILD DATE-") String buildDate) {
this.buildDate = buildDate;
}
public String getBuildDate(){
return this.buildDate;
}
}
The only other context I can give is the exception I get when opening the screen: java.lang.ClassNotFoundException: com.company.deiproductconfig2.core.AspenProperties.
I just don’t know why the class isn’t found. I dunno if I’m missing a step, as mentioned above.
The @ConfigurationPropertiesScan worked. The other issue I had was that I had a .java file in my kotlin directory. One I moved it to my java directory, it worked.
As a side note, what would should the class declaration look like for a Kotlin properties file? I tried to use the covert to Kotlin tool in IntelliJ to generate the Kotlin class but when I ran the app, it seems Spring wasn’t able to find a constructor for the generated class?
I’d appreciate an example of a Kotlin properties class.