Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java dropwizard项目中的默认http/admin端口_Java_Port_Dropwizard - Fatal编程技术网

Java dropwizard项目中的默认http/admin端口

Java dropwizard项目中的默认http/admin端口,java,port,dropwizard,Java,Port,Dropwizard,我有一个dropwizard项目,并且在项目的根目录下维护了一个config.yml文件(基本上与pom.xml处于相同的级别)。在这里,我指定了要使用的HTTP端口,如下所示: http: port:9090 adminPort:9091 我的TestService.java文件中有以下代码 public class TestService extends Service<TestConfiguration> { @Override public

我有一个dropwizard项目,并且在项目的根目录下维护了一个config.yml文件(基本上与pom.xml处于相同的级别)。在这里,我指定了要使用的HTTP端口,如下所示:

http:
    port:9090
    adminPort:9091
我的TestService.java文件中有以下代码

public class TestService extends Service<TestConfiguration> {

    @Override
    public void initialize(Bootstrap<TestConfiguration> bootstrap) {
        bootstrap.setName("test");
    }

    @Override
    public void run(TestConfiguration config, Environment env) throws Exception {
        // initialize some resources here..
    }

    public static void main(String[] args) throws Exception {
        new TestService().run(new String[] { "server" });
    }

}
公共类TestService扩展服务{
@凌驾
公共无效初始化(引导引导引导){
bootstrap.setName(“测试”);
}
@凌驾
公共void运行(TestConfiguration config,Environment env)引发异常{
//在这里初始化一些资源。。
}
公共静态void main(字符串[]args)引发异常{
new TestService().run(新字符串[]{“服务器”});
}
}
我希望config.yml文件用于确定HTTP端口。但是,应用程序似乎总是以默认端口8080和8081启动。还要注意的是,我是在eclipse上运行这个程序的


关于我在这里做错了什么,有什么见解吗?

请尝试按如下方式运行您的服务:

http:
    port:9090
    adminPort:9091
将主方法重写为:

public static void main(String[] args) throws Exception {
        new TestService().run(args);
}
然后在eclipse中转到运行-->运行配置…,为类创建一个新的运行配置,转到
参数
并在“程序参数”中添加“服务器路径/to/config.yml”。如果您将它放在根目录中,它将是“server config.yml”


我相信您没有传递
.yml
文件的位置/名称,因此没有加载您的配置。另一种解决方案是将配置文件的位置添加到要传递到run中的数组中;)

您使用的dropwizard版本是什么?当前使用的版本是0.6.2您的运行配置是什么?您正在运行“server/path/to/yaml”吗?我没有通过运行配置传递任何值。我正在执行上面显示的服务的main()方法。在这里,我将服务器作为一个参数传递。以前尝试过,问题似乎是我的yml文件格式不正确:)。现在它工作了!!