当我尝试键入命令以部署我的servlet时:

mvn clean package wildfly:deploy

我收到错误消息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project wildfly-helloworld: Compilation failure: Compilation failure:
[ERROR] /data/helloworld/src/main/java/org/jboss/as/quickstarts/helloworld/q2Servlet.java:[11,39] package org.apache.commons.codec.binary does not exist
[ERROR] /data/helloworld/src/main/java/org/jboss/as/quickstarts/helloworld/q2Servlet.java:[15,31] package org.apache.commons.dbcp does not exist
[ERROR] /data/helloworld/src/main/java/org/jboss/as/quickstarts/helloworld/q2Servlet.java:[16,31] package org.apache.commons.dbcp does not exist


似乎缺少软件包,我在代码中有:

import org.apache.commons.codec.binary.Hex;
import org.apache.commons.dbcp.ConnectionFactory;
import org.apache.commons.dbcp.DriverManagerConnectionFactory;
import org.apache.commons.dbcp.PoolableConnectionFactory;
import org.apache.commons.dbcp.PoolingDataSource;


我该如何解决,非常感谢

最佳答案

org.apache.commons.dbcpcommons-dbcp罐中

<dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    <version>1.4</version>
</dependency>


org.apache.commons.codec.binarycommons-codec罐中

<dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.9</version>
</dependency>

关于java - Maven项目中缺少org.apache.commons.dbcp软件包,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26770991/

10-14 22:08