Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parametrize the preset json file name in the spring boot configuration #10590

Conversation

renanfranca
Copy link
Contributor

Fix #10553

…nfiguration at application.yml deleted by previous commits
@murdos
Copy link
Contributor

murdos commented Aug 18, 2024

What exactly has changed since #10578?

@renanfranca
Copy link
Contributor Author

What exactly has changed since #10578?

I tagged you in the code comments with explanations. Let me know if it was enough 👍

@murdos
Copy link
Contributor

murdos commented Aug 18, 2024

I tagged you in the code comments with explanations. Let me know if it was enough 👍

I have not received any notification. Maybe you've started a review session that you have not finished?

@renanfranca
Copy link
Contributor Author

I have not received any notification. Maybe you've started a review session that you have not finished?

@murdos: Maybe I don't know how to start a review properly when I am the PR owner. I'll play around with two GitHub accounts in another repository to master it, hahaha ;)

Changes since the previous PR #10578

The bug was fixed by adding this parameter:

@Configuration 
@EnableConfigurationProperties(JHipsterPresetFileProperties.class) 
class JHipsterPresetFilePropertiesConfiguration { 
  
  @Bean 
  JHipsterPresetFile jhipsterPresetFile(JHipsterPresetFileProperties presetFileProperties) { 
    return new JHipsterPresetFile(PresetName.from(presetFileProperties.getName())); 
  } 
}

This was the previous bugged code:

@Configuration 
@EnableConfigurationProperties(JHipsterPresetFileProperties.class) 
class JHipsterPresetFilePropertiesConfiguration { 
  
  @Bean 
  JHipsterPresetFile jhipsterPresetFile() { 
    return new JHipsterPresetFile(new JHipsterPresetFileProperties().getName()); 
  } 
}

I used a value object instead of a string and refactored the code to fit that change:

package tech.jhipster.lite.project.domain.resource; 
  
import tech.jhipster.lite.project.domain.preset.PresetName; 
import tech.jhipster.lite.shared.error.domain.Assert; 
  
public record JHipsterPresetFile(PresetName name) { 
  public JHipsterPresetFile { 
    Assert.notNull("name", name); 
  } 
}

@murdos murdos merged commit b1002f6 into jhipster:main Aug 19, 2024
35 checks passed
class JHipsterPresetFilePropertiesConfiguration {

@Bean
JHipsterPresetFile jhipsterPresetFile(JHipsterPresetFileProperties presetFileProperties) {
Copy link
Member

@pascalgrimaud pascalgrimaud Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, I would use directly @Value in repository, to inject the property, no need to use a Configuration and a Bean

@renanfranca
Copy link
Contributor Author

#10590 (comment)

@murdos , please WDYT about it? (I tagged here, because I am not sure if you received notification 😅)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

preset.json in spring config
3 participants