Rapidoid - Extremely Fast, Simple and Powerful Java Web Framework!

Open source (Apache license). View benchmark... Community: [email protected]

Profiles
  • Application profiles can be configured through command line args or ENV properties.
  • The profiles are useful to conditionally activate application beans or configuration.
  • If no profiles are specified, the default profile will be automatically assigned.
  • Having prod or production profile automatically marks the application environment as production.
  • Rapidoid has built-in default configuration for the profiles default, dev and mysql.
Main.java
import org.rapidoid.config.Conf;
import org.rapidoid.env.Env;
import org.rapidoid.gui.GUI;
import org.rapidoid.setup.App;
import org.rapidoid.setup.On;
 
import java.util.Map;
 
public class Main {
    public static void main(String[] args) {
        App.bootstrap(args, "profiles=mysql,foo");
 
        On.get("/profiles").mvc(() -> GUI.display(Env.profiles()));
 
        Map<String, Object> myConfig = Conf.section("my").toMap();
        On.get("/my").mvc(() -> GUI.grid(myConfig));
    }
}
FooCtrl.java
import org.rapidoid.annotation.Controller;
import org.rapidoid.annotation.GET;
import org.rapidoid.annotation.Profiles;
 
@Controller
@Profiles("foo")
public class FooCtrl {
 
    @GET
    public String hi() {
        return "hi, FOO controller!";
    }
 
}
OtherCtrl.java
import org.rapidoid.annotation.Controller;
import org.rapidoid.annotation.GET;
import org.rapidoid.annotation.Profiles;
 
@Controller
@Profiles("default")
public class OtherCtrl {
 
    @GET
    public String hi() {
        return "hi, OTHER controller!";
    }
 
}
config-foo.yml
my:
  msg: 'hello from Foo!'
config.yml
gui:
  navbar: false
 
my:
  msg: 'hello!'
  desc: 'simple example'
GET /profiles
 mysql
 foo
 dev
GET /my
Key Value
msg hello from Foo!
desc simple example
GET /hi
"hi, FOO controller!"

HTTP server routes information:

Verb Path Zone Content type MVC View name Roles
GET /hi main json
GET /my main html my
GET /profiles main html profiles