-
-
Notifications
You must be signed in to change notification settings - Fork 202
Closed
Labels
Milestone
Description
etc/application.conf
server.port = 8085
src/main/java/App.java
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import com.typesafe.config.ConfigParseOptions;
import com.typesafe.config.ConfigSyntax;
import io.jooby.Environment;
import io.jooby.Jooby;
public class App extends Jooby {
{
get("/", ctx -> "Welcome to Jooby!");
}
public App() {
ConfigParseOptions parseOptions;
parseOptions = ConfigParseOptions
.defaults()
.setSyntax(ConfigSyntax.CONF);
Config config = ConfigFactory.load(parseOptions);
System.out.println(config.getString("server.port")); // ALWAYS outputs 8085
setEnvironment(new Environment(getClassLoader(), config.withFallback(getEnvironment().getConfig())));
}
public static void main(String[] args) {
runApp(args, App::new);
}
}pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>jooby-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--<jooby.version>3.7.0</jooby.version>--> <!-- listening on: http://localhost:8085/-->
<jooby.version>3.8.0</jooby.version> <!-- listening on: http://localhost:8080/-->
</properties>
<dependencies>
<dependency>
<groupId>io.jooby</groupId>
<artifactId>jooby</artifactId>
<version>${jooby.version}</version>
</dependency>
<dependency>
<groupId>io.jooby</groupId>
<artifactId>jooby-jetty</artifactId>
<version>${jooby.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.17</version>
</dependency>
</dependencies>
</project>Executing
java -Dconfig.file=etc/application.conf -classpath (many jars) App
When using 3.7.0:
listening on:
http://localhost:8085/
When using 3.8.0:
listening on:
http://localhost:8080/