I want to pass a table from intellij to postgreSQL using spring boot.
The language used is Kotlin and it is written in gradle.
Information arrives until postman, but not postgreSQL.
Also, no error occurs, so I don't know the cause any more.
Below is my code and dependency.
application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/spring
spring.datasource.username=postgres
spring.datasource.password=1234
UserInfo.kt
import javax.persistence.*
@Entity
data class UserInfo(
@Id val id: String,
var pw: String,
var name: String,
var birth: String
)
Usercontroller.kt
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
import org.springframework.web.bind.annotation.*
import javax.annotation.PostConstruct
@RestController
@EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class])
class UserController {
private val userMap: MutableMap<String, UserInfo> = mutableMapOf()
@PostConstruct
fun init() {
userMap["id1"] = UserInfo("id1", "password1", "Alice", "1001")
userMap["id2"] = UserInfo("id2", "password2", "Rabit", "1101")
userMap["id3"] = UserInfo("id3", "password3", "Card", "1201")
}
@GetMapping(path = ["/user/{id}"])
fun getUserInfo(@PathVariable("id") id: String) = userMap[id]
@GetMapping(path = ["user/all"])
fun getUserInfoAll() = ArrayList<UserInfo>(userMap.values)
@PutMapping(path = ["/user/{id}"])
fun putUserInfo(@PathVariable("id") id: String, @RequestParam("pw") pw: String,
@RequestParam("name") name: String, @RequestParam("birth") birth: String) {
val userInfo = UserInfo(id,pw, name, birth)
userMap[id] = userInfo
}
@PostMapping(path = ["/user/{id}"])
fun postUserInfo(@PathVariable("id") id: String, @RequestParam("pw") pw: String,
@RequestParam("name") name: String, @RequestParam("birth") birth: String){
val userInfo = userMap[id]
userInfo?.pw = pw
userInfo?.name = name
userInfo?.birth = birth
}
@DeleteMapping(path = ["/user/{id}"])
fun deleteUserInfo(@PathVariable("id") id: String) = userMap.remove(id)
}
UserRepository.kt
import org.springframework.data.repository.reactive.ReactiveCrudRepository
import org.springframework.stereotype.Repository
@Repository
interface UserRepository : ReactiveCrudRepository<UserInfo, String
gradle is in the attachment
I think there may be a problem in UserRepository.kt, but I can't find it because there is no error.
Thank you for reading the article. I wish you a nice day.
enter image description here
question from:
https://stackoverflow.com/questions/65849943/error-in-linking-spring-boot-and-postgresqlkotlin