连接被拒绝,来自SprigBoot应用到weblogic的连接

huangapple go评论57阅读模式
英文:

Connection refused from SprigBoot app to weblogic

问题

I'm trying to consume a REST service from Postman by deploying a war artifact in weblogic but always have the same error

> "Error: connect ECONNREFUSED 127.0.0.1:8021"

There's no problem with my IP or port.

This is my application.properties file

连接被拒绝,来自SprigBoot应用到weblogic的连接

and this my request

连接被拒绝,来自SprigBoot应用到weblogic的连接

finally, this is my Controller class

package com.app.controller;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.app.model.Employee;
import com.app.repo.EmployeeRepo;

@RestController
public class EmployeeController {

	@Autowired
	private EmployeeRepo repo;

	@PostMapping("/save")
	public ResponseEntity<String> saveEmployee(@RequestBody Employee employee) {
		try {
			repo.save(employee);
		} catch (Exception e) {
			return new ResponseEntity<String>("Error al insertar", HttpStatus.INTERNAL_SERVER_ERROR);
		}
		return new ResponseEntity<String>("Insertado exitosamente", HttpStatus.OK);
	}
}

Any help, please?

英文:

I'm trying to consume a REST service from Postman by deploying a war arctifact in weblogic but always have the same error

> "Error: connect ECONNREFUSED 127.0.0.1:8021"

There's no problem with my IP or port.

This is my application.properties file

连接被拒绝,来自SprigBoot应用到weblogic的连接

and this my request

连接被拒绝,来自SprigBoot应用到weblogic的连接

finally, this is my Controller class

package com.app.controller;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.app.model.Employee;
import com.app.repo.EmployeeRepo;

@RestController
public class EmployeeController {

	@Autowired
	private EmployeeRepo repo;

	@PostMapping(&quot;/save&quot;)
	public ResponseEntity&lt;String&gt; saveEmployee(@RequestBody Employee employee) {
		try {
			repo.save(employee);
		} catch (Exception e) {
			return new ResponseEntity&lt;String&gt;(&quot;Error al insertar&quot;, HttpStatus.INTERNAL_SERVER_ERROR);
		}
		return new ResponseEntity&lt;String&gt;(&quot;Insertado exitosamente&quot;, HttpStatus.OK);
	}
}

Any help, please?

答案1

得分: 1

如果您的Spring Boot应用程序部署为war文件在WebLogic中,那么它将使用WebLogic端口,而不是您在application.properties文件中配置的端口。

英文:

If your spring boot application is deployed in weblogic as a war file, then it would be using the weblogic ports, not what you have configured in your application.properties file.

huangapple
  • 本文由 发表于 2023年6月26日 05:23:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76552460.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定