本文整理了Java中spark.Spark.setPort()
方法的一些代码示例,展示了Spark.setPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spark.setPort()
方法的具体详情如下:
包路径:spark.Spark
类名称:Spark
方法名:setPort
[英]Set the port that Spark should listen on. If not called the default port is 4567. This has to be called before any route mapping is done.
[中]设置Spark应该监听的端口。如果未调用,则默认端口为4567。在完成任何路由映射之前,必须调用该函数。
代码示例来源:origin: komoot/photon
/**
* start api to accept search requests via http
*
* @param args
* @param esNodeClient
*/
private static void startApi(CommandLineArgs args, Client esNodeClient) {
setPort(args.getListenPort());
setIpAddress(args.getListenIp());
// setup search API
get("api", new SearchRequestHandler("api", esNodeClient, args.getLanguages()));
get("api/", new SearchRequestHandler("api/", esNodeClient, args.getLanguages()));
get("reverse", new ReverseSearchRequestHandler("reverse", esNodeClient, args.getLanguages()));
get("reverse/", new ReverseSearchRequestHandler("reverse/", esNodeClient, args.getLanguages()));
// setup update API
final NominatimUpdater nominatimUpdater = new NominatimUpdater(args.getHost(), args.getPort(), args.getDatabase(), args.getUser(), args.getPassword());
Updater updater = new de.komoot.photon.elasticsearch.Updater(esNodeClient, args.getLanguages());
nominatimUpdater.setUpdater(updater);
get("/nominatim-update", (Request request, Response response) -> {
new Thread(() -> nominatimUpdater.update()).start();
return "nominatim update started (more information in console output) ...";
});
}
}
代码示例来源:origin: cinchapi/concourse
/**
* Start the server.
*/
public void start() {
if(running.compareAndSet(false, true)) {
Spark.setPort(port);
Spark.staticFileLocation(staticFileLocation);
// Register all the EndpointContainers and listen for any requests
Reflections reflections = new Reflections(
"com.cinchapi.concourse.server.http.router");
Set<EndpointContainer> weighted = Sets.newTreeSet();
for (Class<? extends EndpointContainer> container : reflections
.getSubTypesOf(EndpointContainer.class)) {
EndpointContainer instance = Reflection.newInstance(container,
concourse);
weighted.add(instance);
}
for (EndpointContainer instance : weighted) {
initialize(instance);
}
Logger.info("HTTP Server enabled on port {}", port);
}
}
代码示例来源:origin: shekhargulati/todoapp-spark
public static void main(String[] args) throws Exception {
setIpAddress(IP_ADDRESS);
setPort(PORT);
staticFileLocation("/public");
new TodoResource(new TodoService(mongo()));
}
代码示例来源:origin: neo4j-examples/neo4j-movies-java-bolt
public static void main(String[] args) {
setPort(Util.getWebPort());
externalStaticFileLocation("src/main/webapp");
final MovieService service = new MovieService(Util.getNeo4jUrl());
new MovieRoutes(service).init();
}
}
内容来源于网络,如有侵权,请联系作者删除!