简体   繁体   English

Spring和数据库连接的问题

[英]Problem with Spring and database connection

I got a problem with my connection via database and spring.我通过数据库和 spring 的连接出现问题。 I searching in all ends of internet for resolution but without success我在互联网的各个端搜索解决方案但没有成功

My problem is about retrieve my list of class from database to Spring.我的问题是关于将我的类列表从数据库检索到 Spring。 I want to do an electronic journey app, and this is only one thing I cannot pass.我想做一个电子旅行应用程序,这只是我不能通过的一件事。 So my question is -> what i need to get that connection?所以我的问题是 -> 我需要什么才能获得这种联系? ( maybe some ClassDAO , ClassRepository , more) (也许一些ClassDAOClassRepository ,更多)

So, my Class.java looks like this所以,我的 Class.java 看起来像这样

package com.example.JournalElectronic.model;

import javax.persistence.*;
import java.util.List;

@Entity
public class Class {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String classNr;
    private int roomNr;

    public Long getId() {
        return id;
    }

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

    public String getClassNr() {
        return classNr;
    }

    public void setClassNr(String classNr) {
        this.classNr = classNr;
    }

    public int getRoomNr() {
        return roomNr;
    }

    public void setRoomNr(int roomNr) {
        this.roomNr = roomNr;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne
    @JoinColumn(name = "user_id")
    private User user;

}

and my "some" html file ->和我的“一些”html文件->

<div class="btn-group">
<button> class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Klasy
</button>
<tr th:each var="emp" items="${classList}" varStatus="status">
    <tr>
        <td>${status.index + 1}</td>
        <td>${emp.name}</td>
    </tr>
</c:forEach>

And my second is about separate css out of .html file.我的第二个是关于 .html 文件中的单独 css。 My friend added all css actions into .html files, and I want to separate (for good looking code), but if i do with "ref" I cannot see colours and all of my buttons all messed up.我的朋友将所有 css 操作添加到 .html 文件中,我想分开(为了好看的代码),但如果我使用“ref”,我看不到颜色,我的所有按钮都搞砸了。

您是否尝试将 css 代码放在一个单独的 .css 文件中并将其链接到 HTML 像这样<link rel="stylesheet" type="text/css" href="<c:url value="/css/some.css"/>"/> ?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM