Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

hibernate - Quarkus (1.10.4/1.11.0) build. no default datasource found

I am trying to migrate an existing Quarkus (1.7.5) project to Quarkus version 1.11.0 I can build althrough until version 1.10.3. From version 1.10.4 during the build I get the exception below (It is a new feature looking at the changlog #13894 - Throw an exception when model classes and no datasource)

However I am declaring datasources in the application properties according to the documentation using jdbc postgres: https://quarkus.io/guides/hibernate-orm

Had a glimpse at agroal with an quarkus-extension.yaml, didn't help though

What am I missing? Thankful for any Pointers

application.properties

..further declarations
...
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=my_user
quarkus.datasource.password=my_password
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/mydatabase
...
..further declarations
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.11.0.Final:build (default) on project isp-testArch11-core: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#configurationDescriptorBuilding threw an exception: io.quarkus.runtime.configuration.ConfigurationException: Model classes are defined for the default persistence unit but no default datasource found: the default EntityManagerFactory will not be created.
[ERROR]         at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.handleHibernateORMWithNoPersistenceXml(HibernateOrmProcessor.java:697)
[ERROR]         at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.configurationDescriptorBuilding(HibernateOrmProcessor.java:310)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:972)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :isp-testArch11-core

Versions until 1.10.3 do work. Using:

Maven 3.6.3

Java 11

question from:https://stackoverflow.com/questions/65885669/quarkus-1-10-4-1-11-0-build-no-default-datasource-found

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

We figured out what the issue was.

Maven ignored application.properties because in the pom.xml, in the build job, there are addiotional resources declared.

If you do NOT delcare resources, it looks in the default directories like src/main/recources

If you do declare any additional resources you have to declare src/main/recources explicitly as well.

<build>
 <finalName>${project.parent.artifactId}</finalName>
 <resources>
  <resource>
    <directory>../additional_stuff</directory>
    <includes>
      <include>**/*.*</include>
    </includes>
  </resource>
  <resources>
  <resource>
    <directory>src/main/resources</directory>
    <includes>
      <include>**/*.*</include>
    </includes>
  </resource>
</resources>
...
</build>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...