403 Forbidden

编程入门 行业动态 更新时间:2024-10-12 01:31:30
本文介绍了403 Forbidden - 在 Weblogic 中部署 Spring Boot 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个应用程序,我目前正尝试将其转换为 Spring Boot,但在将 Weblogic 配置为运行该应用程序时遇到了问题.我在 HTTP 请求上收到 403 Forbidden 响应.

I have an application that I'm currently trying to convert to Spring Boot but I'm having issues getting Weblogic configured to run the application. I get 403 Forbidden response on HTTP request.

任何帮助将不胜感激!

这是我的 @SpringBootApplication 类.

This is my @SpringBootApplication class.

@SpringBootApplication public class AgisSpringApplication extends SpringBootServletInitializer implements WebApplicationInitializer { public static void main(String[] args) { SpringApplication.run(AgisSpringApplication.class, args); } @Override public void onStartup(ServletContext context) throws ServletException { } }

这是我的weblogic.xml

<?xml version="1.0" encoding="UTF-8"?> <wls:weblogic-web-app xmlns:wls="xmlns.oracle/weblogic/weblogic-web-app" xmlns:xsi="www.w3/2001/XMLSchema-instance" xsi:schemaLocation="java.sun/xml/ns/javaee java.sun/xml/ns/javaee/ejb-jar_3_0.xsd xmlns.oracle/weblogic/weblogic-web-app xmlns.oracle/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd"> <wls:weblogic-version>12.1.3</wls:weblogic-version> <wls:context-root>agis-spring</wls:context-root> <wls:container-descriptor> <wls:prefer-application-packages> <wls:package-name>org.slf4j.*</wls:package-name> </wls:prefer-application-packages> </wls:container-descriptor> </wls:weblogic-web-app>

这是我目前唯一的控制器

@RestController public class MapController { private TemplateService templateService; public MapController(TemplateService templateService) { this.templateService = templateService; } @GetMapping("/") public String getName() throws Exception { return templateService.getTemplate("map.vm"); } }

pom.xml

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="maven.apache/POM/4.0.0" xmlns:xsi="www.w3/2001/XMLSchema-instance" xsi:schemaLocation="maven.apache/POM/4.0.0 maven.apache/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.group</groupId> <artifactId>agis-spring</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>agis-spring</name> <description></description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-velocity</artifactId> <version>1.4.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>

推荐答案

1) 您的 Application.java 看起来不正确.试试这个:

1) your Application.java doesn't look correct. Try this one:

@SpringBootApplication public class Application extends SpringBootServletInitializer implements WebApplicationInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } }

2) 确保您的 weblogic.xml 位于 src/main/webapp/WEB-INF/ 下.

2) Make sure your weblogic.xml is placed under src/main/webapp/WEB-INF/.

3) 确保将应用程序打包到 war 中.

3) Make sure you package the app into war.

<packaging>war</packaging>

4) 确保禁用嵌入式 tomcat.

4) Make sure embedded tomcat is disabled.

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>

5) 我不确定是否可以将 wls:package-name 指定为通配符.根据 spring-启动文档应该是这样的:

5) I'm not sure if wls:package-name can be specified as wildcart. According to spring-boot documentation it should be like this:

<wls:package-name>org.slf4j</wls:package-name>

6) 通过执行 mvn clean package 构建 war 工件.

6) Build the war artifact by performing mvn clean package.

.war 工件将被放置到 your-app/build/lib.使用此文件部署到服务器中.

The .war artifact will be placed to your-app/build/lib. Use this file for deploying into the server.

希望这些提示中的一些能解决问题.

Hope that some of this hints will solve the problem.

更多推荐

403 Forbidden

本文发布于:2023-10-28 10:57:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536439.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Forbidden

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!