//创建一个HttpServer实例,并绑定到指定的IP地址和端口号
HttpServer httpServer = HttpServer.create(new InetSocketAddress(8001), 0);
Path path = Paths.get("src/main/resources/paths.txt");
Stream lines = Files.lines(path);
// 创建一个HttpContext,将所有路径的请求映射到CheckCodeHandler处理器
lines.forEach(
line -> {
if (!line.isEmpty()) {
System.out.println("binding handler:" + line);
httpServer.createContext(line, new CheckCodeHandler());
System.out.println("bound:" + line);
}
});
//设置服务器的线程池对象
httpServer.setExecutor(Executors.newFixedThreadPool(10));
//启动服务器
httpServer.start();
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.7.0
com.gts
auth
0.0.1-SNAPSHOT
gts-auth
auth for gts
1.8
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-maven-plugin