小编use*_*191的帖子

Intellij 运行“JBoss Remote”时出错:无法连接

尝试使用 IntelliJ IDEA 2017.2 将 WAR 远程部署到 Wildfly 10。当我运行时,我收到错误:

Error running 'JBoss Remote': Unable to connect to the www.example.com:9990,
reason: com.intellij.javaee.process.common.WrappedException:
java.io.IOException: java.net.ConnectException: WFLYPRT0053:
Could not connect to remote+http://www.example.com:9990. The connection failed
Run Code Online (Sandbox Code Playgroud)

当我手动访问时,http://www.example.com:9990我会得到 Wildfly 控制台。我可以通过端口 9990 远程登录到我的站点并获得 HTTP 响应。

我已经检查过了。答案对我没有帮助。

问题可能是什么?

java jboss intellij-idea wildfly

6
推荐指数
1
解决办法
2459
查看次数

java嵌套构建器模式重复字段

我在网上遇到的嵌套构建器模式通常是这样的:

class Person{

    private int id;
    private String name;
    private int age;
    ... so on

    private Person(Builder builder){
        this.id = builder.id;
        this.name = builder.name;
        this.age = builder.age;
    }

    public static class Builder{

        private int id;
        private String name;
        private int age;
        ... so on

        public Builder id(int id){
            this.id = id;
            return this;
        }
        public Builder name(String name){
             this.name = name;
             return this;
        }
        .... so on

        public Person build(){
            return new Person(this);
        }

    }

}
Run Code Online (Sandbox Code Playgroud)

我的问题是,是否有必要在Personand 中复制字段 …

java

6
推荐指数
1
解决办法
1397
查看次数

Javafx像回调一样,但是没有返回

我正在寻找一个标准Javafx或java接口(如果存在),该接口的作用类似于Callback,但它不会返回任何值。

该标准Callbackjavafx.util包装如下:

public interface Callback<P,R> {
    public R call(P param);
}
Run Code Online (Sandbox Code Playgroud)

当您需要返回值时,这很有用,但我不需要。我调查了Callable<T>

public interface Callable<V> {
    V call() throws Exception;
}
Run Code Online (Sandbox Code Playgroud)

但这实际上并没有将值传递给call。我要找的基本上是这样的:

public interface Callable<V> {
    void call(V value) throws Exception;
}
Run Code Online (Sandbox Code Playgroud)

是否有标准的Java接口,还是应该只创建自己的接口?

java javafx

5
推荐指数
1
解决办法
214
查看次数

Spring Boot 获取浏览器请求 URL

我有一个简单的休息控制器,可以捕获错误。我想获得浏览器发送到服务器的实际 URL,但 servlet 给了我一个不同的 URL。

如果我导航到127.0.0.1/abc404 错误被触发,它被路由到/error定义的处理程序。但是,输出给了我结果127.0.0.1/error而不是127.0.0.1/abc. 如何获取原始网址?

@RestController
public class IndexController implements ErrorController {

    @RequestMapping("/")
    public String index() {
        return "OK";
    }

    @RequestMapping("/error")
    public String error(HttpServletRequest request) {
        System.out.println("ERR: " + request.getRequestURL() + " : " + request.getRequestURI());
        return "ERR";
    }

    @Override
    public String getErrorPath() {
        return "/error";
    }
}
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

2
推荐指数
1
解决办法
7528
查看次数

Spring Boot(Webflux)休息控制器获取远程IP地址

使用Spring Boot进行简单的REST应用程序。

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

我有一个处理请求的简单控制器。

@RestController
@RequestMapping("/api")
public class MainController {

    @RequestMapping("/test")
    public BasicDTO getBasic(HttpServletRequest request){
        System.out.println(request.getRemoteAddr());
        return new BasicDTO();
    }

}
Run Code Online (Sandbox Code Playgroud)

HttpServletRequest上下文没有获得注入。如何将请求上下文注入方法,以便可以访问一些基本的套接字详细信息?谢谢。

java spring spring-boot spring-webflux

2
推荐指数
1
解决办法
2037
查看次数