I try \"kotlin - spring boot 2 - jpa\".I just started to study spring-boot. I have model, repository and app files. I`m use start.spring.io for starting.I’ve seen examples with
We can create start class-bean
@Component
class StartHere {
@Autowired
lateinit var vkUserRepository: VkUserRepository
fun runHere() {
var users = vkUserRepository.findAll()
println(users)
}
//TODO all other program code here
}
Then in MAIN function we get 'application context' and run our bean-starter
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import ru.program.vkUsersSkill.init.StartHere
@SpringBootApplication
class VkUsersSkillApplication
fun main(args: Array<String>) {
val context = runApplication<VkUsersSkillApplication>(*args)
val start = context.getBean(StartHere::class.java)
start.runHere()
}
All is done. Thanks to @Jonathan Johx.