我已经尝试将我的应用程序与数据库连接,如本网站所述:https://www.visual-paradigm.com/tutorials/hibernateinnetbeans.jsp
我使用MySQL和Maven项目。但其余部分按照网站上的解释方式完成,当我运行CreateAutoPartsStore时,我有这样的输出:
The POM for unknown.binary:orm:jar:SNAPSHOT is missing, no dependency information available
[...]
--- exec-maven-plugin:1.2.1:exec (default-cli) @ AutoPartsStore ---
org.hibernate.HibernateException: /ormmapping/AutoPartsStore.cfg.xml not found
at org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2026)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2007)
at org.orm.PersistentManager.<init>(PersistentManager.java:72)
at autopartstore.AutoPartsStorePersistentManager.<init>(AutoPartsStorePersistentManager.java:31)
at autopartstore.AutoPartsStorePersistentManager.instance(AutoPartsStorePersistentManager.java:41)
at ormsamples.CreateAutoPartsStoreData.main(CreateAutoPartsStoreData.java:65)
这是我的pom.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>AutoPartsStore</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>unknown-jars-temp-repo</id>
<name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>orm</artifactId>
<version>SNAPSHOT</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project>
我找到了一些关于将XML文件复制到另一个位置的问题的解决方案,但是没有一个能为我工作。
答案 0 :(得分:0)
看起来你需要将hibernate jar添加到Maven dependecies列表中。
此:
<dependency>
<groupId>unknown.binary</groupId>
<artifactId>orm</artifactId>
<version>SNAPSHOT</version>
</dependency>
通知maven您的存储库包含工件unknown.binary:orm:jar:SNAPSHOT
,但它似乎从未安装过,显然在Maven Central中不存在以供下载。它有望指向什么?
请注意,位于标记为Maven存储库的文件夹中的.jar不会将其视为已安装。另外,Maven不理解“Jar目录”的概念,如果它没有被声明为依赖,那么它不会自动添加到lib
目录中每个jar的classpath。