Answer the question
In order to leave comments, you need to log in
Spring boot not seeing JpaRepository interface?
Hello everyone, I'm learning spring boot and ran into a problem connecting to the database,
here are all the
spring.properties settings
security.basic.enabled=false
spring.datasource.url=jdbc:mysql://localhost:3306
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
@Repository
interface EmploeeRepository: JpaRepository<Emploee, Int> {
fun findById(id:Int):Emploee
}
@Entity()
@Table(name="robot1")
open class Emploee:Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
var id:Int =0
@Column(name = "name")
var name:String=""
@Column(name="surname")
var surname:String=""
}
@Autowired
lateinit var rep:EmploeeRepository
@RequestMapping("/index")
fun index( model: Model):String
{
println(rep.findById(1).name)
println( )
return "index"
}
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jre8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question