【问题标题】:Can't find url in webLogic deployment在 webLogic 部署中找不到 url
【发布时间】:2023-01-28 06:24:41
【问题描述】:

这是我第一次使用 weblogic 进行部署,我有一个 spring boot 应用程序,当我添加到 weblogic 中时,我找不到我的 rest 调用的路径,在我的主应用程序中,我什至添加了这个日志来查看运行的位置,但我没有输出:

 private static final Logger LOGGER = LoggerFactory.getLogger(KpiApplication.class);
public static void main(String[] args) throws UnknownHostException {
      SpringApplication app = new SpringApplication(KpiApplication.class);
      Environment env = app.run(args).getEnvironment();
      String protocol = "http";
      if (env.getProperty("server.ssl.key-store") != null) {
          protocol = "https";
      }
      System.out.println("LEXA"+ env.getProperty("server.port")+InetAddress.getLocalHost().getHostAddress());
      try {
        LOGGER.info("\n----------------------------------------------------------\n\t" +
                    "Application '{}' is running! Access URLs:\n\t" +
                    "Local: \t\t{}://localhost:{}\n\t" +
                    "External: \t{}://{}:{}\n\t" +
                    "Profile(s): \t{}\n----------------------------------------------------------",
                  env.getProperty("spring.application.name"),
                  protocol,
                  env.getProperty("server.port"),
                  protocol,
                  InetAddress.getLocalHost().getHostAddress(),
                  env.getProperty("server.port"),
                  env.getActiveProfiles());
    } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    SpringApplication.run(KpiApplication.class);
}

}

在我的 weblogic 中,我在本节中看到了这条路径,但我只是说找不到页面:

我要执行的其余部分是这样的,但每次都找不到页面:

@RestController
public class AccountController extends KpiAbstractController {

    @Autowired
    private AccountService accountService;

    @GetMapping("/v1/accounts")
    public ResponseEntity<AccountDTO> getAccounts(@RequestParam @ApiParam("Point of sale owner ID") String ownerPosId,
                                                  @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startPeriod,
                                                  @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endPeriod,
                                                  HttpServletRequest request)

所有的应用程序都已经设置好了,我的经理只是告诉我试试看,但他也不知道链接,请问我在哪里可以找到它

【问题讨论】:

    标签: java spring spring-boot rest weblogic


    【解决方案1】:

    您可以查看我对类似问题的其他回答:https://stackoverflow.com/a/74508358/345130 您是如何完成 Spring Boot 文档“传统部署”部分中所写的内容的?

    同样对于 weblogic,您通常会创建 src/main/webapp/weblogic.xml 文件,您将在其中设置上下文根,例如

    <?xml version="1.0" encoding="UTF-8"?>
    <weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.5/weblogic-web-app.xsd">
        <context-root>myapp</context-root>
    </weblogic-web-app>
    

    这使您的应用程序可以通过 http://server:port/myapp URL 访问。

    您没有提到的另一件事是,如果您有一个单独的 AdminServer 或 AdminServer+ManagedServer?如果信,那么您应该通过 AdminServer 将您的应用程序部署到 ManagedServer 并在 ManagedServer host:port 访问它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多