Lord Tkay
Lord Tkay
Explore posts from servers
JCHJava Community | Help. Code. Learn.
Created by Lord Tkay on 5/29/2024 in #java-help
Best Practice for DTO-Mapping in Spring
Thanks for the answer. Based on what I've seen on a quick search of your libraries, the manual mapping seem to be the best bet at the moment. The request objects will be way different than my business-object in the beginning, because the whole request object need to be refactored anyway. But I will only do one application at a time.
7 replies
JCHJava Community | Help. Code. Learn.
Created by Lord Tkay on 2/25/2024 in #java-help
ConditionalOnBean without creating own config for every bean
So it would look something like
@Configuration
class MyConfig() {
@Bean
@ConditionalOnProperty(["my.property.activate"])
fun mandatory(): Mandatory {
return Mandatory()
}

@Bean
@ConditionalOnBean(value = [Mandatory::class])
fun someClass(mandatory: Mandatory): SomeClass {
return SomeClass(mandatory)
}
}

class SomeClass(var mandatory: Mandatory) {
//...
}
@Configuration
class MyConfig() {
@Bean
@ConditionalOnProperty(["my.property.activate"])
fun mandatory(): Mandatory {
return Mandatory()
}

@Bean
@ConditionalOnBean(value = [Mandatory::class])
fun someClass(mandatory: Mandatory): SomeClass {
return SomeClass(mandatory)
}
}

class SomeClass(var mandatory: Mandatory) {
//...
}
14 replies
JCHJava Community | Help. Code. Learn.
Created by Lord Tkay on 2/25/2024 in #java-help
ConditionalOnBean without creating own config for every bean
Well, in the explicit version I would need to remove the @Component from the class I want to create a bean from
14 replies
JCHJava Community | Help. Code. Learn.
Created by Lord Tkay on 2/25/2024 in #java-help
ConditionalOnBean without creating own config for every bean
Creating a bean-method and creating the object instance explicit instead of letting spring creating the bean for me
14 replies
JCHJava Community | Help. Code. Learn.
Created by Lord Tkay on 2/25/2024 in #java-help
ConditionalOnBean without creating own config for every bean
@piscean72 hmm what a bummer. So best practice would be to manually create all beans that should be conditionally inside of that config of mine?
14 replies