Category Archives: JAVA

[Solved] No converter found for return value of type: class org.json.JSONObject

No converter found for return value of type: class org json. Jsonobject
run error:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; 
nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException:
····································

I can’t see any specific mistakes here

Go to the front page F12 and see the display: no converter found for return value of type: class.org.json.jSONObject

Layer controller code:

//    Update the Users' information
    @ResponseBody
    @RequestMapping(value = "/user/update", method = RequestMethod.POST)
    public Object updateUserMsg(HttpServletRequest req) {
        JSONObject jsonObject = new JSONObject();
        String id = req.getParameter("id").trim();
        String username = req.getParameter("username").trim();
        String password = req.getParameter("password").trim();
        String sex = req.getParameter("sex").trim();
        String phone = req.getParameter("phone").trim();
        String email = req.getParameter("email").trim();
        String birth = req.getParameter("birth").trim();
        String introduction = req.getParameter("introduction").trim();
        String location = req.getParameter("location").trim();
//        String avatar = req.getParameter("avatar").trim();
//        System.out.println(username + "  " + password + "  " + sex + "   " + phone + "     " + email + "      " + birth + "       " + introduction + "      " + location);

        if (username.equals("") || username == null) {
            jsonObject.put("code", 0);
            jsonObject.put("msg", "The Username or Password is Wrong");
            return jsonObject;
        }
        Consumer consumer = new Consumer();
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date myBirth = new Date();
        try {
            myBirth = dateFormat.parse(birth);
        } catch (Exception e) {
            e.printStackTrace();
        }
        consumer.setId(Integer.parseInt(id));
        consumer.setUsername(username);
        consumer.setPassword(password);
        consumer.setSex(new Byte(sex));
        consumer.setPhone(phone);
        consumer.setEmail(email);
        consumer.setBirth(myBirth);
        consumer.setIntroduction(introduction);
        consumer.setLocation(location);
//        consumer.setAvatar(avatar);
        consumer.setUpdateTime(new Date());

        boolean res = consumerService.updateUserMsg(consumer);
        if (res) {
            jsonObject.put("code", 1);
            jsonObject.put("msg", "Modified Successfully");
            return jsonObject;
        } else {
            jsonObject.put("code", 0);
            jsonObject.put("msg", "Failed to Modified");
            return jsonObject;
        }
    }

Reason for error reporting:
java original org.json.jsonobject cannot return JSON data as a return value

solution:
requires

Introduce in POM:

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.47</version>
</dependency>

[Solved] Sping controller Receives list entity parameter Error: nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256

When the controller in spin receives entity parameters
if there is a list attribute in the entity, an error will be reported when the list value is too large

public class Model{
    private List<String> strings;
}

Error Messages: “Invalid property ‘rynrlist[256]’ of bean class [com.ac.intellsecurity.model.exam.records.ExamTrainingRecordsModel]: Index of out of bounds in property path ‘rynrlist[256]’; nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256”

Reason:

Solution:
1. modified into jsonobject to receive parameters and then converted into an entity (recommended)

@RestController
@RequestMapping("/controller")
public class Controller {

    //Before Modified
    @PostMapping("/addModel")
        public AjaxResult addModel(Model model){
        //.........
    }

    //Modified
    @PostMapping("/addModel")
    public AjaxResult addModel(JSONObject json){
        //.........
        Model model = JSONObject.parseObject(json.toJSONString(),Model.class);
    }
}    

2. Add method in controller

@InitBinder
protected void initBinder(WebDataBinder binder) {
    binder.setAutoGrowNestedPaths(true);
    binder.setAutoGrowCollectionLimit(1024);
}

 

SpringMVC Error: Cannot resolve org.springframework:spring-webmvc:5.2.9.RELEASE

Maven import dependency problem

Question:

When adding spring webmvc dependencies, Maven reports an error, while other spring dependencies can be imported.

Cannot resolve org.springframework:spring-webmvc:5.2.9.RELEASE

Debug:

Query the local Maven warehouse: C:\users\sang\M2\repository, find the package that failed to import, and find that it has been imported.

It is speculated that Maven took a wind when importing dependencies. Delete the folder corresponding to the incorrectly imported dependencies, that is, delete the spring webmvc folder and reload all Maven project in the project

At this point, all dependencies are loaded successfully. However, Maven relies on a library with red wavy lines. Just restart idea.

[Solved] Weblogic error: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11G

Error message: Java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11G

After looking at the background, locate the error code as follows

//Save a thumbnail image locally
BufferedImagesrc=ImageIO.read(file2);
FilelocalDir=newFile(GlobalConstants.SAVE_PATH+GlobalConstants.SMALL_IMAGE_SAVE_PATH);
if(!localDir.exists()){
    localDir.mkdirs();
}
//The following code starts reporting errors
BufferedImageoutImg=newBufferedImage(60,60,BufferedImage.TYPE_INT_RGB);
outImg.getGraphics().drawImage(src,0,0,60,60,null);

Solution:

Open the setDomainEnv.sh configuration file under the weblogic domain service bin

Add parameters in the following positions:

JAVA_OPTIONS="${JAVA_OPTIONS} -Djava.awt.headless=true " ​
export JAVA_OPTIONS

[Solved] Springboot Start main program service error: required a single, but 2 were found

required a single , but 2 were found
Error:

***************************
APPLICATION FAILED TO START
***************************
Description:
Field messageService in com.sto.unify.app.jnv2.controller.biz.TaskCenter.TaskCenterController required a single bean, but 2 were found:
    - taskMessageServiceImpl: defined in file [/Users/zgz/IdeaProjects/sto-app-face/sto-app-face-jn/sto-app-face-jn-service/target/classes/com/sto/unify/app/jnv2/service/core/task/impl/TaskMessageServiceImpl.class]
    - taskMessageService: defined in file [/Users/zgz/IdeaProjects/sto-app-face/sto-app-face-jn/sto-app-face-jn-service/target/classes/com/sto/unify/app/jnv2/service/core/task/TaskMessageService.class]
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

Error reason:

It may be that maperscan scans all the packages during scanning. Change it to the following

[Solved] idea Run gui Error: Error:Abnormal build process termination:

Error reported by idea running program:

Error:Abnormal build process termination: 
"C:\Program Files\Java\jdk1.8.0_181\bin\java" -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=\"\" -Djdt.compiler.useSingleThread=true -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djava.net.preferIPv4Stack=true -Dio.netty.initialSeedUniquifier=3130135518625661539 -Dfile.encoding=GBK -Djps.file.types.component.name=CommunityFileTypes -Duser.language=zh -Duser.country=CN -Didea.paths.selector=IdeaIC2017.1 "-Didea.home.path=D:\intellij\IntelliJ IDEA Community Edition 2017.1.3" -Didea.config.path=C:\Users\Administrator\.IdeaIC2017.1\config -Didea.plugins.path=C:\Users\Administrator\.IdeaIC2017.1\config\plugins -Djps.log.dir=C:/Users/Administrator/.IdeaIC2017.1/system/log/build-log "-Djps.fallback.jdk.home=D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/jre64" -Djps.fallback.jdk.version=1.8.0_112-release -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/Administrator/.IdeaIC2017.1/system/compile-server/xmpos_version_1cf37ff8/_temp_ -Djps.backward.ref.index.builder=true -Dkotlin.incremental.compilation.experimental=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"C:\Users\Administrator\AppData\Local\Temp\kotlin-idea-1543655368645972493-is-running\" -classpath "D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_121/lib/tools.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/optimizedFileManager.jar" org.jetbrains.jps.cmdline.Launcher "D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/util.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/snappy-in-java-0.5.1.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/forms_rt.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/openapi.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-builders-6.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/protobuf-2.5.0.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/idea_rt.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jdom.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/resources_en.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/log4j.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/annotations.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/asm-all.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jna-platform.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/nanoxml-2.2.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/oromatcher.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jgoodies-forms.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/trove4j.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-builders.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/netty-all-4.1.9.Final.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-model.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/javac2.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jna.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/commons-io-2.2.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/commons-lang-2.6.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-base-services-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-base-services-groovy-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-cli-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-core-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-logging-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-messaging-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-model-core-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-model-groovy-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-native-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-process-services-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-resources-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-tooling-api-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-tooling-extension-api.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-tooling-extension-impl.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-version-info-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-wrapper-3.3.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/guava-jdk5-17.0.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/jansi-1.14.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/kryo-2.22.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/minlog-1.2.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-freebsd-amd64-libcpp-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-freebsd-amd64-libstdcpp-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-freebsd-i386-libcpp-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-freebsd-i386-libstdcpp-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-amd64-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-amd64-ncurses5-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-amd64-ncurses6-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-i386-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-i386-ncurses5-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-linux-i386-ncurses6-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-osx-amd64-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-osx-i386-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-windows-amd64-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/native-platform-windows-i386-0.12.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/objenesis-1.2.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/reflectasm-1.07.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/resources_en.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/gson-2.5.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/jarutils.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/ant/lib/ant-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/IntelliLang/lib/intellilang-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Groovy/lib/groovy-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Groovy/lib/groovy-rt-constants.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/eclipse/lib/eclipse-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/eclipse/lib/common-eclipse-util.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/gradle/lib/gradle-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/jps/android-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/jps/android-gradle-jps.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/android-common.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/android-rt.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/sdk-common.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/repository.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/sdklib.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/common.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/jarutils.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/layoutlib-api.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/android/lib/manifest-merger.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-runtime.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-reflect.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-android-extensions-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/Kotlin/lib/kotlin-android-extensions-compiler-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/javaFX/lib/javaFX-jps-plugin.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/plugins/javaFX/lib/common-javaFX-plugin.jar" org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 49368 17dc4cd1-443b-4591-a8f4-08f506e32d55 C:/Users/Administrator/.IdeaIC2017.1/system/compile-server
Build process started. Classpath: D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_121/lib/tools.jar;D:/intellij/IntelliJ IDEA Community Edition 2017.1.3/lib/optimizedFileManager.jarError connecting to 127.0.0.1:49368; reason: Connection refused: no further information: /127.0.0.1:49368io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: /127.0.0.1:49368    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)    at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:352)    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:612)  at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:559)    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:476) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Connection refused: no further information
    ... 15 more
Exiting.
---------------------

Delete unused jdks:

Open the control panel, select the program or function, find the unused Java JDK and uninstall it.

[Solved] JAVA Beginners’ Error: Exception in thread “main“ java.io.FileNotFoundException

0x00 overview

During the practice in the Java IO flow chapter, an error was found when running the code, saying that the file path is incorrect.

0x01 solution

Error code

package FileDemo2;

import java.io.File;
import java.io.IOException;

public class FileDemo2 {
    public static void main(String[] args) throws IOException {
        // Requirement 1:Create a file java.txt in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f1 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\FileDemo2\\java.txt");
        System.out.println(f1.createNewFile());
        System.out.println("--------------");


        // Requirement 2:Create a directory in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f2 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\FileDemo2\\JavaSE\\");
        System.out.println(f2.mkdir());
        System.out.println("--------------");

        // Requirement 3:Create a multi-level directory in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory \JavaSE\JavaEE\
        File f3 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\FileDemo2\\JavaSE\\JavaEE\\");
        System.out.println(f3.mkdirs());
        System.out.println("--------------");

        // Requirement 4:Create a file javaSE.txt in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f4 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\FileDemo2\\javaSE.txt");
        System.out.println(f4.createNewFile());
        System.out.println("--------------");
    }
}

For the revised code, add \src

package FileDemo2;

import java.io.File;
import java.io.IOException;

public class FileDemo2 {
    public static void main(String[] args) throws IOException {
        // Requirement 1:Create a file java.txt in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f1 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\src\\FileDemo2\\java.txt");
        System.out.println(f1.createNewFile());
        System.out.println("--------------");


        // Requirement 2:Create a directory in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f2 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\src\\FileDemo2\\JavaSE\\");
        System.out.println(f2.mkdir());
        System.out.println("--------------");

        // Requirement 3:Create a multi-level directory in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory \JavaSE\JavaEE\
        File f3 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\src\\FileDemo2\\JavaSE\\JavaEE\\");
        System.out.println(f3.mkdirs());
        System.out.println("--------------");

        // Requirement 4:Create a file javaSE.txt in the C:\Users\119k\IdeaProjects\d17\FileDemo2\ directory
        File f4 = new File("C:\\Users\\119k\\IdeaProjects\\d17\\src\\FileDemo2\\javaSE.txt");
        System.out.println(f4.createNewFile());
        System.out.println("--------------");
    }
}

The absolute path of the file needs to be obtained in the IDE. Here, copy-absoulte path is used to find that there is more \\src in the file path

[Solved] SpringBoot Project Package to jar Error: ClassNotFound…

After the springboot project is packaged as a jar, it is reported to find the main method, classnotfound

Add the following plug-in to the POM of the modules that report the error.

    <build>
       <plugins>
           <!-- If you don't add this parameter to the jar package, it will report that the main method was not found. -->
           <plugin>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-maven-plugin</artifactId>
               <version>2.4.1</version>
               <configuration>
                   <includeSystemScope>true</includeSystemScope>
                   <mainClass>cn.vantee.EurekaServerStarter7001</mainClass>
               </configuration>
               <executions>
                   <execution>
                       <goals>
                           <goal>repackage</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
       </plugins>
    </build>