springboot项目部署JBOSS成功但访问404
来源:互联网 发布:python 完成端口 编辑:程序博客网 时间:2024/06/05 22:37
近期遇到部署springboot项目到jboss项目,遇到了jboss服务器日志显示部署成功且生成上下文,但是访问出线404。
springboot version:1.5.9.RELEASE
jboss version:EPA 6.4
猜测是项目虽然部署jboss成功但是jboss无法找到上下文。解决方案如下:
1.pom.xml添加servlet依赖
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope></dependency>
2 自定义webApplicationInitializer
import javax.servlet.ServletContext;import javax.servlet.ServletException;import javax.servlet.ServletRegistration.Dynamic;import org.springframework.context.annotation.Configuration;import org.springframework.web.WebApplicationInitializer;import org.springframework.web.context.WebApplicationContext;import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;import org.springframework.web.servlet.DispatcherServlet;@Configurationpublic class WebApplicationInitializerImpl implements WebApplicationInitializer{ @Override public void onStartup(ServletContext container) throws ServletException { WebApplicationContext context = getContext(); Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet(context)); registration.setLoadOnStartup(1); registration.addMapping("/*"); } private WebApplicationContext getContext() { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.setConfigLocation(ApplicationMain.class.getName()); return context; } }3.把ApplicationMain启动类添加到SpringApplicationBuilder
@SpringBootApplicationpublic class ApplicationMain extends SpringBootServletInitializer{ @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(ApplicationMain.class); } public static void main(String[] args) { SpringApplication.run(ApplicationMain.class, args); }}
4 在application.yml文件把该项目的domain指定好,JBOSS容器中如果超过2个springboot项目需要添加。
spring: jmx: default-domain: leotest
endpoints: jmx: domain: leotest unique-names: true
阅读全文
0 0
- springboot项目部署JBOSS成功但访问404
- 20151230 远程部署成功,但访问时出现404错误
- springboot JPA项目部署JBOSS出错
- java web项目部署成功后 总是404不能访问
- Eclipse 项目部署成功却访问不到 报错404
- 如何通过域名访问阿里云部署的springboot项目
- MyEclipse+jboss部署项目出现404
- jboss部署web项目
- SpringBoot项目部署到tomcat遇404
- springboot项目 部署tomcat
- springboot项目部署
- weblogic项目部署成功后,访问报403或者404错误
- Tomcat项目部署成功,页面访问404,Work目录权限问题
- eclipse启动tomcat成功,可以访问tomcat主页,但项目访问不了
- Tomcat启动成功但无法访问 访问时报404
- JBOSS部署项目之后,无法通过IP地址访问,只能通过localhost或者127.0.0.1访问
- Eclipse启动jboss,停留在Starting JBoss ...,但可以访问。
- jboss项目部署的操作
- android资料集合整理
- 安全框架Shiro和Spring Security比较
- Python读取mdb文件以及shell检测
- ZooKeeper的典型应用场景之分布式队列。
- java面试题(一)------乐视mysql
- springboot项目部署JBOSS成功但访问404
- 微软Everyday AI发布会:四大工具把AI带到你身边
- 聚类、K-Means、例子、细节
- asp在本地正常,在服务器上报无法识别的属性“targetFramework”,我改了版本显示文件不存在404,从微软官网下载.net包就正常了
- 19.springboot发送mail
- 为什么上面这段代码没有直接写的 function add (){...} 而是把function赋值给了变量add呢?
- Tomcat优化
- 分类算法之朴素贝叶斯分类(Naive Bayesian classification)
- GIT 检查、撤销修改简明教程