application.yml jpa: default: on next line will fail loading EntityManager if it does not have a space in front of it #3955
-
I was following the Micronaut JPA and Hibernate tutorial https://guides.micronaut.io/micronaut-data-access-jpa-hibernate/guide/index.html trying to setup a Micronaut Version: 2.0.0.RC1 application in Eclipse Version: 2019-09 R (4.13.0) with JPA and Hibernate and came across this issue that took me days to try to figure out because I had no idea why EntityManager was not loading. If you specify in application.yml something like this: Your EntityManager will fail to load when running Micronaut along with any repository calls that would be made depending on EntityManager. The default: must be prefixed with at lease one space on the next line or this issue will occur. I was using Eclipse and the editor would let me know that default: needed to be on the next line after jpa: but it did not tell me it was going to fail loading the EntityManager if I did not put a space in front of default: after moving default: to the next line. Ideally I would like the this to either have not have been an issue or the Eclipse editor tell me that I the format was wrong not putting a space in front of default: I would be great if at compilation time when setting up a Micronaut application with JPA and Hibernate if the compiler can tell you if EntityManager will be able to load properly and if it can't, then tell you what you need to to do to get it to load properly so you don't have to be trying to get it to work and have no idea why it isn't working. Also it would be great if there was documentation somewhere on how to define application.yml. It just seemed like I couldn't find anything easily outside of referring to example projects. And the example projects were usually limited to how to setup an H2 database and not showing you how to setup an application.yml for say an Oracle database (what's used where I work). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Compilation errors would requiring parsing the In terms of examples your best source is https://micronaut.io/launch/ If you select the
I have converted this a discussion for the moment but if you have any concrete PRs for improvements to the docs that would help others in the future contributions are welcome. |
Beta Was this translation helpful? Give feedback.
Compilation errors would requiring parsing the
application.yml
file in the compiler which we don't really want to do. The best thing you can do is use an IDE that highlights the errors like IntelliJ IDEA.In terms of examples your best source is https://micronaut.io/launch/
If you select the
oracle
feature it will show you how to setup a datasource. This can be done via the command line as well:I have converted this a discussion for the moment but if you have any concrete PRs for improvements to the docs that would help others in the future contributions are welcome.