在我的本地计算机上,我的其余API可以完美运行。但是我托管在服务器上。然后,当我调用post方法时,它返回错误。但是GET方法运行完美。两种方法都可以在我的本地计算机上使用。 This is my error
以下是我的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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.Mobios</groupId>
<artifactId>DigitalWallet</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.9.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.0.9.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.0.9.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>5.0.9.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.6.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.12.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.thetransactioncompany/cors-filter -->
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
这是我的方法
@RequestMapping(value = "/origin/sendcredit/", method = RequestMethod.POST)
// @Transactional(rollbackFor = DWException.class)
public String addSubCredit(
@RequestBody AddMoneyToOriginVM sendCreditToOriginVM/* ,@RequestParam("hashedValue") String hashedValue */,
HttpServletResponse response) throws Exception {
// checkPlainAndHashed.check("ascc","cdscwc");
// Log4JUtil.logger.info("SendCredit|Start|Transaction=" + sendCreditToOriginVM.toString() + "|"
// + sendCreditToOriginVM.getSender_mobile_number() + " to "
// + sendCreditToOriginVM.getReceiver_mobile_number() + " amount " + sendCreditToOriginVM.getAmount() + "|"
// + sendCreditToOriginVM.getTransaction_Type_id());
String Text = "";
try {
String receiver = sendCreditToOriginVM.getReceiver_mobile_number();
String sender = sendCreditToOriginVM.getSender_mobile_number();
int pin = sendCreditToOriginVM.getSender_pin();
double amount = sendCreditToOriginVM.getAmount();
try {
Origin dbReceiver = originService.findByNumber(receiver);
Origin dbSender = originService.findByNumber(sender);
if (originService.findByNumberAndPin(sender, pin) != null) {
double a = Double.parseDouble(encodeDecode.Decode(dbSender.getWallet().getAmount()));
if (a < amount) {
throw new InsufficientBalanceException();
} else {
if (dbReceiver == null) {
OriginVM newOrigin = new OriginVM();
newOrigin.setMobile_number(receiver);
newOrigin.setOrigin_types_id(3);
newOrigin.setSuper_mobile_number(sender);
newOrigin.setStatus_id(1);
newOrigin.setSuper_pin(pin);
newOrigin.setWallet_amount(amount);
newOrigin.setMembership_types_id(5);
newOrigin.setTransaction_Type_id(1);
addOrigin(newOrigin, response);
} else {
SaveTransaction(dbSender, dbReceiver, amount, 2, "Debit", "Credit");
}
dbReceiver = originService.findByNumber(receiver);
dbSender = originService.findByNumber(sender);
try {
Text = "0|Transaction Successfull"
+ encodeDecode.Decode(String.valueOf(dbReceiver.getWallet().getAmount())) + "|"
+ encodeDecode.Decode(String.valueOf(dbSender.getWallet().getAmount()));
} catch (Exception e) {
throw new RuntimeException("Roll Me Back");
}
Log4JUtil.logger.info("SendCredit|End|Transaction=" + sendCreditToOriginVM.toString() + "|"
+ sendCreditToOriginVM.getSender_mobile_number() + " to "
+ sendCreditToOriginVM.getReceiver_mobile_number() + " amount "
+ sendCreditToOriginVM.getAmount() + "|"
+ sendCreditToOriginVM.getTransaction_Type_id());
}
} else {
throw new AgentValidationFailedException();
}
} catch (DWException exp) {
throw exp;
}
} catch (DWException ex) {
// Log4JUtil.logger.info("Origine|Exception|Transaction=" + sendCreditToOriginVM.toString() + "|"
// + sendCreditToOriginVM.getSender_mobile_number() + " to "
// + sendCreditToOriginVM.getReceiver_mobile_number() + " amount " + sendCreditToOriginVM.getAmount()
// + "|" + ex.toString());
response.sendError(ex.getErrorCode(), ex.getErrorMessage());
}
return Text;
}
这是服务器Java版本 openjdk版本“ 1.8.0_191” OpenJDK运行时环境(内部版本1.8.0_191-b12) OpenJDK 64位服务器VM(内部版本25.191-b12,混合模式)