关于用Java编写文件的怪异问题

如何解决关于用Java编写文件的怪异问题

启动程序时,它需要3个参数,分别为input.txtdata.txtoutput.txt。它将data.txt中的歌曲信息保存到LinkedList,并通过处理input.txt中的命令来执行操作。 input.txt(例如列表)中的某些命令将信息打印到output.txt文件中。

input.txt的内容:

Add id:12 name:"Sandik" singer:"Muslum Gurses" year:2009 count:5 price:20
Add id:15 singer:"Tarkan" name:"Adimi Kalbine Yaz" year:2010 count:10 price:20
Add id:20 name:"Fear of the Dark" singer:"Iron Maiden" year:1992 count:20 price:15
Add id:25 name:"Dark Side of the moon" singer:"Almora" year:1987 count:5 price:10
Remove id:12
List
Edit id:15 singer:"Tarkan Tevetoglu"
Search "ark"
Sell 20
List
Quit

data.txt的内容:

<id>; <price>; <name>; <singer>; <year>; <count>

15;20;Adimi Kalbine Yaz; Tarkan Tevetoglu;2010;10
12;20;Sandik;Muslum Gurses;2009;5
20;15;Fear of the Dark;Iron Maiden;1992;20

预期的output.txt:

New CD added id: 12 name:"Sandik"
New CD added id: 15 name:"Adimi Kalbine Yaz"
New CD added id: 20 name:"Fear of the Dark"
New CD added id: 25 name:"Dark Side of the moon"
CD removed id: 12


List (12 is removed)
Id   Price                     Name         Singer      Year      Count
-----------------------------------------------------------------------
15      20        Adimi Kalbine Yaz         Tarkan      2010         10
25      10    Dark Side of the moon         Almora      1984          5
20      20         Fear of the Dark    Iron Maiden      1992         20


Edit CD id: 15
Id   Price                     Name              Singer      Year      Count
----------------------------------------------------------------------------
15      20        Adimi Kalbine Yaz    Tarkan Tevetoglu      2010         10


Id   Price                     Name         Singer      Year      Count
-----------------------------------------------------------------------
15      20        Adimi Kalbine Yaz         Tarkan      2010         10
25      10    Dark Side of the moon         Almora      1984          5
20      20         Fear of the Dark    Iron Maiden      1992         20


Search "ark”
Id   Price                     Name         Singer      Year      Count
-----------------------------------------------------------------------
25      10    Dark Side of the moon         Almora      1984          5
20      20         Fear of the Dark    Iron Maiden      1992         20


CD sold id: 20
Id   Price                     Name         Singer      Year      Count
-----------------------------------------------------------------------
15      20        Adimi Kalbine Yaz         Tarkan      2010         10
25      10    Dark Side of the moon         Almora      1984          5
20      20         Fear of the Dark    Iron Maiden      1992         20


Quit
Cash: 20
Best Seller: Fear of the Dark

我的程序包含2个类,MainLinkedList。我写了这个程序,一切正常。但是,在开发程序时,我正在控制台上进行实验。我完成了程序,并且在更改打印部分以打印到文件而不是控制台时,我的程序爆炸了。在解释导致问题的部分之前,我想分享我的代码。

主类:

import java.io.*;
import java.util.Scanner; // Import the Scanner class to read text files


public class Main {
    public static void main(String[] args) throws IOException {
        int i = 0;
        /* Start with the empty list. */
        LinkedList list = new LinkedList(args);
        int id1 = 0,year1 = 0,count1 = 0,price1 = 0;
        String name1 = "",singer1 = "";

        //The contents of data.txt have been loaded into the program.
        try {
            Scanner scan = new Scanner(new File(args[1]));
            while (scan.hasNextLine()) {

                String data = scan.nextLine();
                String[] readedData = data.split(";");
                LinkedList.insert(list,id1 = Integer.parseInt(readedData[0]),price1 = Integer.parseInt(readedData[1]),name1 = readedData[2],singer1 = readedData[3],year1 = Integer.parseInt(readedData[4]),count1 = Integer.parseInt(readedData[5]));
            }
            scan.close();
        } catch (FileNotFoundException e) {
            System.out.println("An error occurred.");
            e.printStackTrace();
        }

        //The object required to write to the file has been created.
        //FileWriter myWriter = new FileWriter(args[2]);
        PrintStream output1 = new PrintStream(args[2]);

        //The input.txt file has started to be read.
        try {
            Scanner scan = new Scanner(new File(args[0]));
            while (scan.hasNextLine()) {
                String data = scan.nextLine();

                // First,split on whitespace
                //String[] parts = data.split("(?<!\"\\w\")\\s+(?!\\w+\")"); //Alternate Solution

                String[] parts = data.split("\\s(?=\\w+:)");
                String[] parts1 = data.split("(?<!\"\\w\")\\s+(?!\\w+\")");
                String command1 = parts1[0];

                // The first element in the array is the command
                String command = parts[0];
                // Split the remaining elements on ':'
                String[] keyVal;
                String key = " ";
                String value= " ";
                for (i = 1; i < parts.length; i++) {
                    keyVal = parts[i].split(":");
                    if (keyVal.length == 2) {
                        key = keyVal[0];
                        value = keyVal[1];
                        switch (key) {
                            case "id" -> id1 = Integer.parseInt(value);
                            case "name" -> name1 = value.substring(1,value.length() - 1);
                            case "singer" -> singer1 = value.substring(1,value.length() - 1);
                            case "year" -> year1 = Integer.parseInt(value);
                            case "count" -> count1 = Integer.parseInt(value);
                            case "price" -> price1 = Integer.parseInt(value);
                        }
                    }
                }
                switch (command1) {
                    case "Add" -> {
                        LinkedList.insert(list,id1,price1,name1,singer1,year1,count1);                //DONE!
                        output1.print("New CD added id: "+id1+" name: "+name1);
                        output1.println();
                    }
                    case "Search" -> {
                        output1.print("List:\n");
                        String[] key1 = command.split(" ");
                        String SearchKey = key1[1];
                        SearchKey = SearchKey.substring(1,SearchKey.length() - 1);
                        LinkedList.searchAndFind(list,SearchKey);
                        output1.println();
                    }
                    case "Remove" -> {
                        LinkedList.deleteNode(list,LinkedList.searchPosition(list,id1));                  //DONE!
                        output1.print("CD removed id: "+id1);
                        output1.println();
                    }
                    case "List" -> {
                        output1.print("List:\n");
                        LinkedList.printList(list);
                        output1.println();
                    }
                    case "Edit" -> {
                        output1.print("Edit CD id: "+id1);
                        output1.println();
                        switch (key) {
                            case "singer" -> LinkedList.editSinger(list,singer1);
                            case "name" -> LinkedList.editName(list,name1);
                            case "year" -> LinkedList.editYear(list,year1);                         //DONE!
                            case "count" -> LinkedList.editCount(list,count1);
                            case "price" -> LinkedList.editPrice(list,price1);
                        }
                        output1.println();
                    }
                    case ("Sell") -> {
                        LinkedList.sell(list,id1);
                        output1.print("CD Sold. ID: "+id1);                                                //DONE!
                        output1.println();
                    }
                    case "Quit" -> {
                        output1.print("Quit");
                        output1.println();
                        output1.print("Cash :"+LinkedList.cash);
                        output1.println();
                    }
                }
            }
            scan.close();
        } catch (FileNotFoundException e) {
            System.out.println("An error occurred.");
            e.printStackTrace();
        }
        output1.close();
    }
}

LinkedList类:

import java.io.IOException;
import java.io.PrintStream;

public class LinkedList {

    Node head; // head of list

    public String[] args;

    static PrintStream output = null;
    public LinkedList(String[] args) throws IOException {
        this.args = args;
        output = new PrintStream(args[2]);
    }

    static class Node {

        int id;
        int year;
        int count;
        int price;
        String name;
        String singer;

        Node next;

        // Constructor
        Node(int i,int p,String n,String s,int y,int c) {
            id = i;
            year = y;
            count = c;
            price = p;
            name = n;
            singer = s;

            next = null;
        }
    }

    public static LinkedList insert(LinkedList list,int i,int c)
    {
        // Create a new node with given data
        Node new_node = new Node(i,p,n,s,y,c);
        new_node.next = null;

        // If the Linked List is empty,// then make the new node as head
        if (list.head == null) {
            list.head = new_node;
        }
        else {
            // Else traverse till the last node
            // and insert the new_node there
            Node last = list.head;
            while (last.next != null) {
                last = last.next;
            }

            // Insert the new_node at last node
            last.next = new_node;
        }

        // Return the list by head
        return list;
    }

    public static void printList(LinkedList list)
    {
        Node currNode = list.head;

        output.printf("%s %10s %30s %25s %15s %10s","ID","Price","Name","Singer","Year","Count");
        output.println("\n-------------------------------------------------------------------------------------------------");
        // Traverse through the LinkedList
        while (currNode != null) {
            // Print the data at current node
            output.printf("%s %10s %30s %25s %15s %10s",currNode.id,currNode.price,currNode.name,currNode.singer,currNode.year,currNode.count);

            // Go to next node
            currNode = currNode.next;
            output.println();
        }
        output.println();
    }

    public static void deleteNode(LinkedList list,int position)
    {
        // If linked list is empty
        if (list.head == null)
            return;

        // Store head node
        Node temp = list.head;

        // If head needs to be removed
        if (position == 0)
        {
            list.head = temp.next;   // Change head
            return;
        }

        // Find previous node of the node to be deleted
        for (int i=0; temp!=null && i<position-1; i++)
            temp = temp.next;

        // If position is more than number of nodes
        if (temp == null || temp.next == null)
            return;

        // Node temp->next is the node to be deleted
        // Store pointer to the next of node to be deleted
        Node next = temp.next.next;

        temp.next = next;  // Unlink the deleted node from list
    }

    static int search = 0;
    static int cash = 0;
    public static int searchPosition(LinkedList list,int x)
    {
        search = 0;
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                break;
            }
            current = current.next;
            search++;
        }
        return search;
    }

    public static int sell(LinkedList list,int x)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                cash = cash + current.price;
                break;
            }
            current = current.next;
        }
        return cash;
    }

    public static void editName(LinkedList list,int x,String a)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.name = a;
                output.printf("\n\n%s %10s %30s %25s %15s %10s","Count");
                output.println("\n-------------------------------------------------------------------------------------------------");
                output.printf("%s %10s %30s %25s %15s %10s",current.id,current.price,current.name,current.singer,current.year,current.count);
                break;
            }
            current = current.next;
        }

    }
    public static void editSinger(LinkedList list,String a)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.singer = a;
                output.printf("\n\n%s %10s %30s %25s %15s %10s",current.count);
                break;
            }
            current = current.next;
        }
    }
    public static void editYear(LinkedList list,int a)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.year = a;
                output.printf("\n\n%s %10s %30s %25s %15s %10s",current.count);
                break;
            }
            current = current.next;
        }
    }
    public static void editCount(LinkedList list,int a)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.count = a;
                output.printf("\n\n%s %10s %30s %25s %15s %10s",current.count);
                break;
            }
            current = current.next;
        }
    }
    public static void editPrice(LinkedList list,int a)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.price = a;
                output.printf("\n\n%s %10s %30s %25s %15s %10s",current.count);
                break;
            }
            current = current.next;
        }
    }
    public static void searchAndFind(LinkedList list,String a)
    {
        Node current = list.head;    //Initialize current
        output.printf("\n\n%s %10s %30s %25s %15s %10s","Count");
        output.println("\n-------------------------------------------------------------------------------------------------");
        while (current != null)
        {
            if (current.name.contains(a)){
                output.printf("%s %10s %30s %25s %15s %10s",current.count);
                output.println();
            }
            current = current.next;
        }
    }
}

当我运行程序时,打印到output.txt文件的输出不正确,并对其进行了调试。当我的程序进入开关结构时,读取了第一个命令add,并执行了操作,一切都很好。直到读取List命令为止。 List命令之前的所有命令都可以正常工作,并且一切都很好,但是当读取List时,printList类中的LinkedList函数可以正常工作。此行开始运行后,我的output.txt文件已损坏。 output.printf ("% s% 10s% 30s% 25s% 15s% 10s","Count");

并且每次运行output.print类中的LinkedList命令时,我的output.txt文件都会进一步损坏。我认为问题可能是由2个单独的对象写在同一文件中引起的。我不确定,但是它们可能会发生冲突。我该如何解决这个问题或有更实际的方法?如果您能提供帮助,我将不胜感激。预先感谢。

解决方法

例如,我通过将在Main中创建的名为output1的对象发送到将在读取add命令时调用的函数并在LinkedList类中使用该函数来解决该问题。

LinkedList类:

import java.io.*;

public class LinkedList {
    Node head; // head of list

    public String[] args;

    public LinkedList(String[] args){
        this.args = args;
    }

    static class Node {

        int id;
        int year;
        int count;
        int price;
        String name;
        String singer;

        Node next;

        // Constructor
        Node(int i,int p,String n,String s,int y,int c) {
            id = i;
            year = y;
            count = c;
            price = p;
            name = n;
            singer = s;

            next = null;
        }
    }

    public static LinkedList insert(LinkedList list,int i,int c)
    {
        // Create a new node with given data
        Node new_node = new Node(i,p,n,s,y,c);
        new_node.next = null;

        // If the Linked List is empty,// then make the new node as head
        if (list.head == null) {
            list.head = new_node;
        }
        else {
            // Else traverse till the last node
            // and insert the new_node there
            Node last = list.head;
            while (last.next != null) {
                last = last.next;
            }

            // Insert the new_node at last node
            last.next = new_node;
        }

        // Return the list by head
        return list;
    }

    public static void printList(LinkedList list,PrintStream x)
    {
        Node currNode = list.head;

        x.printf("%s %10s %30s %25s %15s %10s","ID","Price","Name","Singer","Year","Count");
        x.println("\n-------------------------------------------------------------------------------------------------");
        // Traverse through the LinkedList
        while (currNode != null) {
            // Print the data at current node
            x.printf("%s %10s %30s %25s %15s %10s",currNode.id,currNode.price,currNode.name,currNode.singer,currNode.year,currNode.count);

            // Go to next node
            currNode = currNode.next;
            x.println();
        }
        x.println();
    }

    public static void deleteNode(LinkedList list,int position)
    {
        // If linked list is empty
        if (list.head == null)
            return;

        // Store head node
        Node temp = list.head;

        // If head needs to be removed
        if (position == 0)
        {
            list.head = temp.next;   // Change head
            return;
        }

        // Find previous node of the node to be deleted
        for (int i=0; temp!=null && i<position-1; i++)
            temp = temp.next;

        // If position is more than number of nodes
        if (temp == null || temp.next == null)
            return;

        // Node temp->next is the node to be deleted
        // Store pointer to the next of node to be deleted
        Node next = temp.next.next;

        temp.next = next;  // Unlink the deleted node from list
    }

    static int search = 0;
    static int cash = 0;
    public static int searchPosition(LinkedList list,int x)
    {
        search = 0;
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                break;
            }
            current = current.next;
            search++;
        }
        return search;
    }

    public static int sell(LinkedList list,int x)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                cash = cash + current.price;
                break;
            }
            current = current.next;
        }
        return cash;
    }

    public static void editName(LinkedList list,int x,String a,PrintStream y)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.name = a;
                y.printf("\n\n%s %10s %30s %25s %15s %10s","Count");
                y.println("\n-------------------------------------------------------------------------------------------------");
                y.printf("%s %10s %30s %25s %15s %10s",current.id,current.price,current.name,current.singer,current.year,current.count);
                break;
            }
            current = current.next;
        }

    }
    public static void editSinger(LinkedList list,PrintStream y)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.singer = a;
                y.printf("\n\n%s %10s %30s %25s %15s %10s",current.count);
                break;
            }
            current = current.next;
        }
    }
    public static void editYear(LinkedList list,int a,PrintStream y)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.year = a;
                y.printf("\n\n%s %10s %30s %25s %15s %10s",current.count);
                break;
            }
            current = current.next;
        }
    }
    public static void editCount(LinkedList list,PrintStream y)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.count = a;
                y.printf("\n\n%s %10s %30s %25s %15s %10s",current.count);
                break;
            }
            current = current.next;
        }
    }
    public static void editPrice(LinkedList list,PrintStream y)
    {
        Node current = list.head;    //Initialize current
        while (current != null)
        {
            if (current.id == x){
                current.price = a;
                y.printf("\n\n%s %10s %30s %25s %15s %10s",current.count);
                break;
            }
            current = current.next;
        }
    }
    public static void searchAndFind(LinkedList list,PrintStream y)
    {
        Node current = list.head;    //Initialize current
        y.printf("\n\n%s %10s %30s %25s %15s %10s","Count");
        y.println("\n-------------------------------------------------------------------------------------------------");
        while (current != null)
        {
            if (current.name.contains(a)){
                y.printf("%s %10s %30s %25s %15s %10s",current.count);
                y.println();
            }
            current = current.next;
        }
    }
}

主类:

import java.io.*;
import java.util.Scanner; // Import the Scanner class to read text files


public class Main {
    public static void main(String[] args) throws IOException {
        int i = 0;
        /* Start with the empty list. */
        LinkedList list = new LinkedList(args);
        int id1 = 0,year1 = 0,count1 = 0,price1 = 0;
        String name1 = "",singer1 = "";

        //The contents of data.txt have been loaded into the program.
        try {
            Scanner scan = new Scanner(new File(args[1]));
            while (scan.hasNextLine()) {

                String data = scan.nextLine();
                String[] readedData = data.split(";");
                LinkedList.insert(list,id1 = Integer.parseInt(readedData[0]),price1 = Integer.parseInt(readedData[1]),name1 = readedData[2],singer1 = readedData[3],year1 = Integer.parseInt(readedData[4]),count1 = Integer.parseInt(readedData[5]));
            }
            scan.close();
        } catch (FileNotFoundException e) {
            System.out.println("An error occurred.");
            e.printStackTrace();
        }

        //The object required to write to the file has been created.
        //FileWriter myWriter = new FileWriter(args[2]);
        PrintStream output1 = new PrintStream(args[2]);

        //The input.txt file has started to be read.
        try {
            Scanner scan = new Scanner(new File(args[0]));
            while (scan.hasNextLine()) {
                String data = scan.nextLine();

                // First,split on whitespace
                //String[] parts = data.split("(?<!\"\\w\")\\s+(?!\\w+\")"); //Alternate Solution

                String[] parts = data.split("\\s(?=\\w+:)");
                String[] parts1 = data.split("(?<!\"\\w\")\\s+(?!\\w+\")");
                String command1 = parts1[0];

                // The first element in the array is the command
                String command = parts[0];
                // Split the remaining elements on ':'
                String[] keyVal;
                String key = " ";
                String value= " ";
                for (i = 1; i < parts.length; i++) {
                    keyVal = parts[i].split(":");
                    if (keyVal.length == 2) {
                        key = keyVal[0];
                        value = keyVal[1];
                        switch (key) {
                            case "id" -> id1 = Integer.parseInt(value);
                            case "name" -> name1 = value.substring(1,value.length() - 1);
                            case "singer" -> singer1 = value.substring(1,value.length() - 1);
                            case "year" -> year1 = Integer.parseInt(value);
                            case "count" -> count1 = Integer.parseInt(value);
                            case "price" -> price1 = Integer.parseInt(value);
                        }
                    }
                }
                switch (command1) {
                    case "Add" -> {
                        LinkedList.insert(list,id1,price1,name1,singer1,year1,count1);                //DONE!
                        output1.print("New CD added id: "+id1+" name: "+name1);
                        output1.println();
                    }
                    case "Search" -> {
                        output1.print("List:\n");
                        String[] key1 = command.split(" ");
                        String SearchKey = key1[1];
                        SearchKey = SearchKey.substring(1,SearchKey.length() - 1);
                        LinkedList.searchAndFind(list,SearchKey,output1);
                        output1.println();
                    }
                    case "Remove" -> {
                        LinkedList.deleteNode(list,LinkedList.searchPosition(list,id1));                  //DONE!
                        output1.print("CD removed id: "+id1);
                        output1.println();
                    }
                    case "List" -> {
                        output1.print("List:\n");
                        LinkedList.printList(list,output1);
                        output1.println();
                    }
                    case "Edit" -> {
                        output1.print("Edit CD id: "+id1);
                        output1.println();
                        switch (key) {
                            case "singer" -> LinkedList.editSinger(list,output1);
                            case "name" -> LinkedList.editName(list,output1);
                            case "year" -> LinkedList.editYear(list,output1);                         //DONE!
                            case "count" -> LinkedList.editCount(list,count1,output1);
                            case "price" -> LinkedList.editPrice(list,output1);
                        }
                        output1.println();
                    }
                    case ("Sell") -> {
                        LinkedList.sell(list,id1);
                        output1.print("CD Sold. ID: "+id1);                                                //DONE!
                        output1.println();
                    }
                    case "Quit" -> {
                        output1.print("Quit");
                        output1.println();
                        output1.print("Cash :"+LinkedList.cash);
                        output1.println();
                    }
                }
            }
            scan.close();
        } catch (FileNotFoundException e) {
            System.out.println("An error occurred.");
            e.printStackTrace();
        }
        output1.close();
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res