英文:
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
and this my request
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
and this my request
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?
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论