Reputation: 67
Hey I want to make projects using databases. I've found some tutorials on youtube, but I have problem with Java JPA/Hibernate. Even tho I am following each step I just cant get to import in my class
import javax.persistence.EntityManage
I am using IntelliJ and here is how I am trying to do it. First I create maven project without archetypes. Then in my pom.xml file which for some reason looks different than the one in tutorial.
I am adding dependencies.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.28.Final</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
The second one might not be needed, but I am trying everything at this point. At the end my pom.xml file looks like:
<?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>org.example</groupId>
<artifactId>BD</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.28.Final</version>
</dependency>
</dependencies>
</project>
In my pom file there are no errors. I have also made persistence.xml file, but the problem appears before it matters. I've spent few hours looking for solution and I am so angry at myself that I cant get over such a easy thing, but I have no idea what am I doing wrong. I literally follow tutorial that clearly works.
Upvotes: 0
Views: 5240
Reputation: 171
IntelliJ IDEA sometimes needs a little help to refresh dependencies declared in pom.xml:
You can manually re-import dependencies by following procedure:
More info is provided in official docs:
Upvotes: 2