使用Stripe时Maven编译错误:找不到符号APIException,APIConnectionException

问题描述 投票:0回答:1

我正在尝试将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

我收到两个编译错误:

找不到符号:class APIConnectionException location:package com.stripe.exception

找不到符号:class APIException location:package com.stripe.exception

任何帮助表示赞赏。

java maven jsp servlets stripe-payments
1个回答
1
投票

删除以下import语句后编译的项目:

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
© www.soinside.com 2019 - 2024. All rights reserved.