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

Bug: Props can not be found with MicronautBeanProcessor #84

Open
cemo opened this issue Jun 25, 2020 · 3 comments
Open

Bug: Props can not be found with MicronautBeanProcessor #84

cemo opened this issue Jun 25, 2020 · 3 comments
Labels
info: workaround available A workaround is available for the issue type: bug Something isn't working

Comments

@cemo
Copy link
Contributor

cemo commented Jun 25, 2020

I am not sure this is the correct repo or not but I am trying to make use MicronautBeanProcessor.

My problem is that Micronaut can not resolve Spring's properties.

For EachProperty part of DataJdbcConfiguration configuration:

https://github.com/micronaut-projects/micronaut-data/blob/c1d1dc3cdee0e73125e1bc58d05c05d23c1e0633/data-jdbc/src/main/java/io/micronaut/data/jdbc/config/DataJdbcConfiguration.java#L34-L35

@EachProperty(value = DataJdbcConfiguration.PREFIX, primary = "default")
public class DataJdbcConfiguration implements Named {

it triggers:

@Override
public <T> Optional<T> getProperty(String name, ArgumentConversionContext<T> conversionContext) {
return Optional.ofNullable(environment.getProperty(name, conversionContext.getArgument().getType()));
}

However name's value is datasources. When it delegates to Spring it can not find this property. datasouces.default.url works.

I am little surprised why this is not hit before.

my prop is like this:

datasources:
  default:
    url: "jdbc:mysql://localhost:3306/cemo?useSSL=false"
    username: "root"
    password: ""
    driverClassName: com.mysql.cj.jdbc.Driver
```

Any help?
@graemerocher
Copy link
Contributor

Can you provide an example?

@cemo
Copy link
Contributor Author

cemo commented Jun 25, 2020

@graemerocher

https://github.com/cemo/micronaut-spring-84 here is the example.

  1. put a breakpoint DefaultEnvironment#getProperty inside MicronautBeanProcessor. You will see that it is not resolved.

@Override
public <T> Optional<T> getProperty(String name, ArgumentConversionContext<T> conversionContext) {
return Optional.ofNullable(environment.getProperty(name, conversionContext.getArgument().getType()));
}

I make it raise an error on RegionService class to show that something is not configured correctly.

PS: After resolving all issues using Micronaut data inside Spring will be so beautiful :)

@cemo
Copy link
Contributor Author

cemo commented Jun 25, 2020

Another approach can be using Spring's property sources as Micronaut.

https://gist.github.com/cemo/b26b1fb8bc814e2213b1f43dedf6a2bc/

This is working.

@ilopmar ilopmar added info: workaround available A workaround is available for the issue type: bug Something isn't working labels Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info: workaround available A workaround is available for the issue type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants