我正在尝试将Stripe Java库与JSP Java servlet一起使用。
我已将以下库导入到servlet acceptpaymentrequest.java中:
import com.stripe.Stripe;
import com.stripe.exception.APIConnectionException;
import com.stripe.exception.APIException;
import com.stripe.exception.AuthenticationException;
import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException;
import com.stripe.model.Charge;
我的pom.xml如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jsp.payments</groupId>
<artifactId>payments-app</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>payments-app Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<tomcat.version>9.0.0.M6</tomcat.version>
</properties>
<dependencies>
...
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>8.1.0</version>
</dependency>
</dependencies>
<build>
<finalName>payments-app</finalName>
<resources>
<resource>
<directory>src/main/webapp</directory>
<targetPath>META-INF/resources</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>payments-app-${project.version}</finalName>
<archive>
<manifest>
<mainClass>com.jsp.payments.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
当我运行命令
mvn compile
我遇到两个编译错误:
找不到符号:类APIConnectionException 位置:包com.stripe.exception
找不到符号:类APIException 位置:包com.stripe.exception
感谢您的帮助。
答案 0 :(得分:1)
在删除以下导入语句后编译的项目:
import com.stripe.exception.APIConnectionException;
import com.stripe.exception.APIException;
import com.stripe.exception.AuthenticationException;
import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException;
并且根据官方的Stripe Java API文档仅导入了这一条:
import com.stripe.exception.StripeException