The premise

Today, I planned to test a small function in my front end, but I had to create some data by myself, so I wrote several interfaces in Java, but I encountered the following problems in the process of building the project. # Failed to bind properties to mappers under ‘mapper.mappers’ Table ‘hh_my_test.user’ doesn’t exist, meaning a Table in the database doesn’t exist

The cause of the problem

The reason for the first problem is that I forgot to complete the class name when configuring application.xml and only wrote the package name. I did not write this at the beginning. MyMapper.

But also pay attention to one point, is set to scan the packet, can not be the universal mapper packet scan, so set @MapperScan(basePackages = {"com.hhzj.mapper"})Hhzj. mapper, all mappers are placed in com.hhzj.mapper, and the generic mapper is named in a separate package space

Note that mapper and myMapper packages are the same, so the generic mapper is not scanned by Spring. If it is scanned, it will cause problems

The class name in my POJO is User, but the name of the database table is user_login, so there will be a problem when mapping in mapper. The solution is to add @table (name = “user_login”)

The front part

<! DOCTYPEhtml>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form method="post" action="user/login">
    <input type="text" name="userEmail" placeholder="Please enter user email address">
    <input type="text" name="username" placeholder="Please enter user name">
    <input type="password" name="password" placeholder="Please enter user password">
    <input class="sumbit" type="submit" value="Submit">
</form>

<script>const submit = document.querySelector(".sumbit") const userEmail = document.querySelector("input[name='userEmail']") userEmail.setAttribute("value", "[email protected]") const username = document.querySelector("input[name='username']") username.setAttribute("value", "root") const password = document.querySelector("input[name='password']") // username.setAttribute("value", "Root123 ") Default password cannot be set let userEmailValue = useremail. value let usernameValue = username. Value let passwordValue = password.value userEmail.addEventListener("input", function () { userEmailValue = this.value }) username.addEventListener("input", function () { usernameValue = this.value }) password.addEventListener("input", function () { passwordValue = this.value }) submit.addEventListener("click", function (e) { const data = { userEmail: userEmailValue, username: usernameValue, password: passwordValue } let xhr = new XMLHttpRequest() xhr.open("post", `user/login`) xhr.setRequestHeader("Content-Type", "application/json") xhr.addEventListener("load", Function (data) {console.log(data)}) xhr.send(json.stringify (data)) # This e.preventDefault() is a test to block the form's default submission event.</script>
</body>
</html>
Copy the code