启动工程报错:java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
15:03:26.534 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
    at com.alibaba.nacos.sys.utils.DiskUtils.forceMkdir(DiskUtils.java:284)
    at com.alibaba.nacos.core.listener.StartingApplicationListener.makeWorkDir(StartingApplicationListener.java:208)
    at com.alibaba.nacos.core.listener.StartingApplicationListener.environmentPrepared(StartingApplicationListener.java:79)
    at com.alibaba.nacos.core.code.SpringApplicationRunListener.environmentPrepared(SpringApplicationRunListener.java:65)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:342)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236)
    at com.alibaba.nacos.NacosApplication.main(NacosApplication.java:39)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 10 common frames omitted

原因:

需要同时引用commons-lang3和commons-io。

我就是因为缺少了commons-io包才报错的

1
2
3
4
5
6
7
8
9
10
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.4</version>
</dependency>
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.2</version>
</dependency>

 转自:http://blog.superabbit.cn/article/detail/a7a1be1831984403a8ce0060d21b3a12