Hello,
Following this guide, I have managed to create a restfull api with kotlin, and make it work with Intelji, but I can not find the way to deploy it on my Tomcat server, making it completely independent of the programming environment.
Application.kt
import com.example.blog.conectores.MySQLDatabaseExampleKotlin
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
@SpringBootApplication
class Application
fun main(args: Array<String>) {
//Arrancar Webservice
SpringApplication.run(Application::class.java, *args)
}
ProfileController.kt
import com.example.blog.Greeting
import com.example.blog.Profile
import com.example.blog.ProfileID
import com.example.blog.conectores.MySQLDatabaseExampleKotlin
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import java.util.concurrent.atomic.AtomicLong
@RestController
class ProfileController {
val counter = AtomicLong()
var nombre:String = ""
var apellidos:String = ""
var id_usuario:String =""
@GetMapping("/profile")
fun profile(@RequestParam(value = "id", defaultValue = "0") id: String) =
//Profile(counter.incrementAndGet(), nombre(id), id_usuario(id))
ProfileID(counter.incrementAndGet(), id_usuario(id))
fun id_usuario(name:String):String{
MySQLDatabaseExampleKotlin.getConnection()
id_usuario = MySQLDatabaseExampleKotlin.executeMySQLQuery("user_id", "bdapptest.tb_users", "name = \"$name\"")
return id_usuario
}
}
Running it from Intellij works correctly, but if I upload the War to Tomcat.
Any idea or thread to throw?
Thank you