环境配置采用jfinal-undertow 3.5版本、Jfinal5.1.2版本
<dependencies> <dependency> <groupId>com.jfinal</groupId> <artifactId>jfinal-undertow</artifactId> <version>3.5</version> </dependency> <dependency> <groupId>com.jfinal</groupId> <artifactId>jfinal</artifactId> <version>5.1.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> </dependency> </dependencies>
在Eclipse中,通过运行main方法,项目能够正常运行。
Starting JFinal 5.1.2 Info: jfinal-undertow 3.5, undertow 2.2.24.Final, jvm 1.8.0_202 十月 24, 2023 3:10:51 下午 org.xnio.Xnio <clinit> INFO: XNIO version 3.8.7.Final 十月 24, 2023 3:10:51 下午 org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.8.7.Final 十月 24, 2023 3:10:52 下午 io.undertow.Undertow start INFO: starting server: Undertow - 2.2.24.Final 十月 24, 2023 3:10:52 下午 org.jboss.threads.Version <clinit> INFO: JBoss Threads version 3.1.0.Final Starting Complete in 1.8 seconds. Welcome To The JFinal World (^_^) Server running at: > Local: http://localhost:80 > Network: http://131.10.11.131:80
但是在IDEA Community版本中,始终出现异常,缺少servlet api的包
"C:\Program Files\Java\jdk1.8.0_202\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\lib\idea_rt.jar=61700:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_202\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\rt.jar;E:\GitWorkstation\aliyun\SefonSoftware\telecomBillSystem\billSystemManage\locman-produce\target\classes;D:\maven_repository\.m2\repository\com\jfinal\jfinal-undertow\3.5\jfinal-undertow-3.5.jar;D:\maven_repository\.m2\repository\io\undertow\undertow-core\2.2.24.Final\undertow-core-2.2.24.Final.jar;D:\maven_repository\.m2\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;D:\maven_repository\.m2\repository\org\jboss\xnio\xnio-api\3.8.7.Final\xnio-api-3.8.7.Final.jar;D:\maven_repository\.m2\repository\org\wildfly\common\wildfly-common\1.5.4.Final\wildfly-common-1.5.4.Final.jar;D:\maven_repository\.m2\repository\org\wildfly\client\wildfly-client-config\1.0.1.Final\wildfly-client-config-1.0.1.Final.jar;D:\maven_repository\.m2\repository\org\jboss\xnio\xnio-nio\3.8.7.Final\xnio-nio-3.8.7.Final.jar;D:\maven_repository\.m2\repository\org\jboss\threads\jboss-threads\3.1.0.Final\jboss-threads-3.1.0.Final.jar;D:\maven_repository\.m2\repository\io\undertow\undertow-servlet\2.2.24.Final\undertow-servlet-2.2.24.Final.jar;D:\maven_repository\.m2\repository\com\jfinal\jfinal\5.1.2\jfinal-5.1.2.jar" com.cdsf.locman.produce.config.ProduceConfig Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/ServletException at com.cdsf.locman.produce.config.ProduceConfig.main(ProduceConfig.java:49) Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletException 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) ... 1 more
在Pom.xml文件中,加上了servlet 2.5版本和javax.servlet-api 4.0.1版本都会出现这个错误。
切换切换JDK1.8 到JDK11都会出现这个问题。
求解....常用IDEA
项目:JFinal