TomasWild
09/14/2024, 12:58 PMe: Platform declaration clash: The following declarations have the same JVM signature (getPassword()Ljava/lang/String;):
fun `<get-password>`(): String defined in com.test.model.User
fun getPassword(): String? defined in com.test.model.UserWhat is the most common approach for this? Is it something recurring using Spring Boot with Kotlin?
@Entity
@Table(name = "user")
class User(
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
var id: Long? = null,
@NotEmpty(message = "First name cannot be empty.")
@Column(name = "first_name")
var firstName: String,
@NotEmpty(message = "Last name cannot be empty.")
@Column(name = "last_name")
var lastName: String,
@NotEmpty(message = "Email cannot be empty.")
@Email(message = "Invalid email.")
var email: String,
@NotEmpty(message = "Password cannot be empty.")
var password: String,
@Enumerated(value = EnumType.STRING)
var role: Role,
) : UserDetails {
override fun getAuthorities(): Collection<GrantedAuthority?>? {
return mutableListOf()
}
override fun getPassword(): String? {
return password
}
override fun getUsername(): String? {
return email
}
}
Youssef Shoaib [MOD]
09/14/2024, 1:01 PM@set:JvmName("_getPassword") var password: String
TomasWild
09/14/2024, 1:34 PMphldavies
09/14/2024, 1:35 PM@get:
not @set:
TomasWild
09/14/2024, 1:42 PMokarm
09/14/2024, 3:37 PMokarm
09/14/2024, 3:39 PM@field:
on your constructor properties, otherwise they will be ignored by the validation engine - assuming you use HIbernate Validator.okarm
09/14/2024, 3:42 PMTomasWild
09/14/2024, 3:48 PMokarm
09/14/2024, 3:55 PMgetEmail
and getPassword
as String
since your User properties are never null.