【问题标题】:Maven Compilation Error while using Stripe: Cannot find symbol APIException, APIConnectionException使用 Stripe 时出现 Maven 编译错误:找不到符号 APIException、APIConnectionException
【发布时间】:2019-08-20 08:42:27
【问题描述】:

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

感谢任何帮助。

【问题讨论】:

    标签: java maven jsp servlets stripe-payments


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 2015-11-06
      • 1970-01-01
      • 2019-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-17
      • 1970-01-01
      • 2023-03-30
      相关资源
      最近更新 更多