gpt4 book ai didi

java - 使用 Stripe 时 Maven 编译错误 : Cannot find symbol APIException, APIConnectionException

转载 作者:行者123 更新时间:2023-11-30 05:42:26 24 4
gpt4 key购买 nike

我正在尝试将 Stripe Java 库与 JSP Java servlet 一起使用。

我已将以下库导入到 servletaccept paymentrequest.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

我收到两个编译错误:

cannot find symbol: class APIConnectionException location: package com.stripe.exception

cannot find symbol: class APIException location: package com.stripe.exception

感谢任何帮助。

最佳答案

删除以下导入语句后编译项目:

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

关于java - 使用 Stripe 时 Maven 编译错误 : Cannot find symbol APIException, APIConnectionException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55416890/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com