degath
degath

Reputation: 1621

SpringBoot with JPA in IntelliJ

I'm just starting with Spring, and actually I'm step by step tutorial so everything would work well, but somehow I've got problem with running spring boot after adding JPA elements.

Earlier I had problem with Database type NONE, so I manually added depedency:

        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>10.12.1.1</version>
            <scope>runtime</scope>
        </dependency>

But I feel that still something is missing in pom file which looks like this: Pom.XML

Consol output with an error looks like this: Console output

Implementation: 1. class Topic 2. class TopicController 3. class TopicRepository 4. class: TopicService 5. run class

Upvotes: 1

Views: 149

Answers (1)

Cristian Colorado
Cristian Colorado

Reputation: 2040

You need to annotate Topic class:

package defaultpackage.topic;

/**
 * Created by zales on 02.03.2017.
 */
@Entity
public class Topic {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String id;
    private String name;
    private String discription;


    public Topic() {
    }

    public Topic(String id, String name, String discription) {
        super();
        this.id = id;
        this.name = name;
        this.discription = discription;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDiscription() {
        return discription;
    }

    public void setDiscription(String discription) {
        this.discription = discription;
    }
}

You can see a similar sample with Entities and Repositories in here:

https://github.com/ccoloradoc/HibernateFilePermissionSample

Also make sure all your entities are in same package(or subpackage) as your SpringBootApplication.

Upvotes: 2

Related Questions