“Injeksi Ketergantungan Kotlin” Kode Jawaban

Injeksi Ketergantungan Kotlin

class Bug {
   lateinit var desc: String;
   lateinit var latestComment: String;
   
    // a setter method so that the Spring container can inject desc and latestComment dependencies
   @Autowired
   fun updateBug(desc: String, latestComment: String) {
       this.desc = desc;
       this.latestComment = latestComment;
   }
}
Smoggy Snail

Injeksi Ketergantungan Kotlin

@Component
class Car @Autowired constructor (private val owner: Owner) {
    fun getOwner() : Owner {
        return owner
    }
}

class Owner(private val name: String, private val address: String) {}
Smoggy Snail

Jawaban yang mirip dengan “Injeksi Ketergantungan Kotlin”

Pertanyaan yang mirip dengan “Injeksi Ketergantungan Kotlin”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya