相关疑难解决方法(0)

如何通过Windows命令行关闭TCP和UDP端口

有人知道如何通过Windows命令行关闭单个连接的TCP或UDP套接字?

谷歌搜索这个,我看到有些人问同样的事情.但答案看起来像netstat或netsh命令的手册页,侧重于如何监控端口.我不想要如何监控它们的答案(我已经这样做了).我想关闭/杀死他们.

编辑,澄清:假设我的服务器侦听TCP端口80.客户端建立连接并为其分配端口56789.然后,我发现这种连接是不受欢迎的(例如,这个用户正在做坏事,我们要求他们停止但是连接不会在途中被丢弃).通常情况下,我会添加防火墙来完成这项工作,但这需要一些时间,而且我处于紧急状态.杀死拥有连接的进程在这里确实是一个坏主意,因为这会占用服务器(当我们只想选择性地暂时删除这一个连接时,所有用户都将失去功能).

networking

143
推荐指数
9
解决办法
65万
查看次数

为什么我的Spring Boot App在启动后会立即关闭?

这是我的第一个Spring Boot代码.不幸的是,它总是关闭.我希望它能够连续运行,以便我的Web客户端可以从浏览器获取一些数据.

package hello;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;

@Controller
@EnableAutoConfiguration
public class SampleController {

    @RequestMapping("/")
    @ResponseBody
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(SampleController.class, args);
    }
}


[@localhost initial]$ java -jar build/libs/gs-spring-boot-0.1.0.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/ …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

143
推荐指数
8
解决办法
14万
查看次数

Spring REST 控制器未映射

我正在尝试创建监听“/login”的 à Rest 控制器我已经定义了下面的代码但是当我打开http://localhost:8080/login 时我收到一个 404 错误...请帮忙:)

这是我的包结构:

com.my.package
   |_ Application.java
   |_ controller
          |_ LoginController
Run Code Online (Sandbox Code Playgroud)

我的应用程序:

@ComponentScan("com.my.package.controller")
@SpringBootApplication
public class Application {
    public static void main(String[] args){
        SpringApplication.run(Application.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的休息控制器:

@RestController
public class LoginController {

    @RequestMapping("/login")
    public @ResponseBody String getLogin(){
        return "{}";
    }
}
Run Code Online (Sandbox Code Playgroud)

java rest spring controller

5
推荐指数
2
解决办法
8665
查看次数

SpringBoot的RequestMapping不起作用

我正在学习用于构建应用程序的Spring Boot。我正在尝试使用与应用程序不同包装的控制器来构建我的第一个Spring Boot应用程序。Tomcat实例出现,但请求未到达为URI注册的RestController。

以下是控制器类:

package com.spring.controllers;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping(value = "/abc")
    public String getHi() {
        System.out.println("End Point hit");
        return "Hi";
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是应用程序类:

package com.spring.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackages = {"com.spring.controllers"})
public class SpringBootMain {

    public static void main(String args[]) {
        SpringApplication.run(SpringBootMain.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

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>RandomProjects</groupId>
<artifactId>SpringBoot</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <java.version>1.8</java.version>
</properties>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin> …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

5
推荐指数
2
解决办法
9488
查看次数

Spring Boot Rest API + Spring Batch

我正在研究 Spring Batch 过程,但我的文档没有阐明流程。

我有一个 API,它接收一个具有固定位置的平面文件。该文件具有页眉、正文和页脚特定布局。

我想创建一个具有一个页眉、一个详细信息列表和一个页脚类的文件类。

我现在所知道的是,我必须使用一个令牌来识别每个页眉、详细信息和页脚的位置,但我发现的有关 Spring 批处理的所有内容都没有显示如何执行此操作并从 API 请求启动该过程。

spring spring-batch spring-boot

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

404-not-found-while-running-spring-boot-rest-api

运行 springboot restservice 应用程序时出现 404 错误。我正在使用弹簧靴,球衣休息。我尝试过 GET 请求,http://localhost:8080/dunames但无法解决。请帮忙。

型号分类:

@Entity
@Table(name = "du")
public class duname {


    private String duname;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id; 
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public duname()
    {

    }

    public duname(String duname, int id)
    {
    this.duname=duname; 
    this.id=id;
    }


    public String getDuname() {
        return duname;
    }

    public void setDuname(String duname) {
        this.duname = duname;
    }
}
Run Code Online (Sandbox Code Playgroud)

服务等级:

public class duservice { …
Run Code Online (Sandbox Code Playgroud)

java rest spring-boot

4
推荐指数
1
解决办法
3万
查看次数

标签 统计

java ×4

spring ×4

spring-boot ×4

rest ×2

controller ×1

networking ×1

spring-batch ×1