These are the first steps of creating a spring-boot project. However, even compiled into jar files, the cold start time still takes long After about 140,000 requests, the service response time would become stable.
If you are still a spring framework user, be sure to switch to Akka framework and give it a try.
- Generate:
spring init -d=jersey --build=gradle --lang=groovy app
- Create Config
package com.example.app
import org.springframework.context.annotation.Configuration
import org.glassfish.jersey.server.ResourceConfig
@Configuration
class JerseyConfig extends ResourceConfig {
def JerseyConfig() {
return register(TestResource.class);
}
}
- Add Resource
package com.example.app
import javax.ws.rs.GET
import javax.ws.rs.Produces
import javax.ws.rs.Pah
@Path("/")
class TestResource {
@GET
@Produces("text/plain")
def String getMessage() {
return "Hello World!";
}
}
- Test Run:
cd app
./gradlew bootRun
- List Built Components:
cd app
./gradlew components
- Build:
cd app
./gradlew bootRepackage
# The result jar resides in build/libs/*
# you could run java -jar on such file directly for execution
# and be easier to deploy to other places