会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132464个问题
Python 全系列/第十三阶段:高并发性能怪兽-Tornado 框架/Tornado项目(旧) 34591楼
JAVA 全系列/第三阶段:数据库编程/MySQL数据库的使用 34592楼
Python 全系列/第一阶段:Python入门/函数和内存分析 34593楼
JAVA 全系列/(旧的隐藏)第十二阶段:spring全家桶(Spring Cloud)/Spring Cloud 34594楼
WEB前端全系列/第十三阶段:微信小程序-安心食疗(旧)/安心食疗-项目基础配置 34595楼

屏幕截图 2023-12-03 145152.png

Python 全系列/第五阶段:数据库编程/项目-音乐播放器 34596楼

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
class Send1 extends Thread{
    private Socket socket;
    private Scanner scanner;
    public Send1(Socket socket,Scanner scanner){
        this.scanner=scanner;
        this.socket=socket;
    }
    public void run(){
        this.sendMsg();

    }
    private void sendMsg(){
        try(PrintWriter pw=new PrintWriter(this.socket.getOutputStream())
        ){  while (true){
            String msg=scanner.nextLine();

            pw.println(msg);

            pw.flush();

        }


        }catch (Exception w){
            w.printStackTrace();
        }

    }
}
class Receive1 extends Thread{
    private Socket socket;
    public Receive1(Socket socket){
        this.socket=socket;
    }
    public void Run(){
        this.receiveMsg();

    }
    private void receiveMsg(){
        try( BufferedReader br=new BufferedReader(new InputStreamReader(this.socket.getInputStream()))){
            while (true){
                String mag=br.readLine();
                System.out.println("他说:"+mag);

            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
public class GoodTCP {
    public static void main(String[] args) {
        ServerSocket serverSocket=null;
        Socket socket=null;
        Scanner scanner=null;
        try{
             scanner=new Scanner(System.in);
            System.out.println("输入:server,<port>或者:<ip>,<port>");
            String str=scanner.nextLine();
            String[] arr = str.split(",");
            if ("server".equals(arr[0])){
                //启动服务端
                System.out.println("TCP Server Listen at"+arr[1]+"..........");
                serverSocket=new ServerSocket(Integer.parseInt(arr[1]));
                socket=serverSocket.accept();
            }else{
                socket=new Socket(arr[0],Integer.parseInt(arr[1]));
                System.out.println("连接成功");
            }
            new Send1(socket,scanner).start();
            new Receive1(socket).start();

        }catch (Exception e){
            e.printStackTrace();
        }finally {
          if(serverSocket!=null){
                try {
                    serverSocket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
        }
    }
}

可以正常运行,就是两个窗口,连接不到一块


JAVA 全系列/第二阶段:JAVA 基础深化和提高/网络编程 34598楼
Python 全系列/第一阶段:Python入门/编程基本概念 34600楼

image.png

Maven.rar

我是用的都是mysql8版本的,总是报错

JAVA 全系列/第八阶段:Linux入门到实战/Maven 34602楼
Python 全系列/第四阶段:函数式编程和核心特性/装饰器深入剖析 34604楼

老师,我在执行了maven insatll的命令后出现了一下错误,怎么办

[INFO] Scanning for projects...

[INFO] 

[INFO] -----------------------< com.bjsxt:01mavenDemo >------------------------

[INFO] Building 01mavenDemo 0.0.1-SNAPSHOT

[INFO] --------------------------------[ jar ]---------------------------------

[INFO] 

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ 01mavenDemo ---

[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

[INFO] Copying 0 resource

[INFO] 

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ 01mavenDemo ---

[INFO] Changes detected - recompiling the module!

[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!

[INFO] Compiling 2 source files to D:\eclipse\01mavenDemo\target\classes

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR : 

[INFO] -------------------------------------------------------------

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

[INFO] 1 error

[INFO] -------------------------------------------------------------

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.842 s

[INFO] Finished at: 2019-09-07T11:00:59+08:00

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project 01mavenDemo: Compilation failure

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

[ERROR] -> [Help 1]

[ERROR] 

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR] 

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Maven 34605楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637