Jboss部署SpringBoot2 JPA
目录结构
1 2 3 4 5
| . └── webapp └── META-INF ├── jboss-deployment-structure.xml └── jboss-web.xml
|
jboss-deployment-structure.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| <?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <exclude-subsystems>
<subsystem name="jpa" /> <subsystem name="org.hibernate" /> <subsystem name="org.hibernate.validator" />
<subsystem name="logging" /> </exclude-subsystems> <exclusions> <module name="org.slf4j" /> <module name="org.slf4j.impl" />
<module name="javaee.api" /> <module name="javax.persistence.api" /> <module name="org.hibernate" /> <module name="javax.validation.api"/> <module name="org.hibernate.validator"/> </exclusions>
<dependencies>
<module name="javax.validation.api" export="true"/> <module name="javax.activation.api" export="true" /> <module name="javax.annotation.api" export="true" /> <module name="javax.ejb.api" export="true" /> <module name="javax.el.api" export="true" /> <module name="javax.enterprise.api" export="true" /> <module name="javax.enterprise.deploy.api" export="true" /> <module name="javax.inject.api" export="true" /> <module name="javax.interceptor.api" export="true" /> <module name="javax.jms.api" export="true" /> <module name="javax.jws.api" export="true" /> <module name="javax.mail.api" export="true" /> <module name="javax.management.j2ee.api" export="true" />
<module name="javax.resource.api" export="true" /> <module name="javax.rmi.api" export="true" /> <module name="javax.security.auth.message.api" export="true" /> <module name="javax.security.jacc.api" export="true" /> <module name="javax.servlet.api" export="true" /> <module name="javax.servlet.jsp.api" export="true" /> <module name="javax.transaction.api" export="true" /> <module name="javax.validation.api" export="true" /> <module name="javax.ws.rs.api" export="true" services="export" /> <module name="javax.xml.bind.api" export="true" /> <module name="javax.xml.registry.api" export="true" /> <module name="javax.xml.soap.api" export="true" /> <module name="javax.xml.ws.api" export="true" /> <module name="javax.api" export="true" />
<module name="org.jboss.logging.jul-to-slf4j-stub" export="true" />
</dependencies> </deployment> </jboss-deployment-structure>
|
jboss-web.xml
1 2 3 4 5
| <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd"> <jboss-web> <context-root>app</context-root> </jboss-web>
|
有时启动后requestmapping无法正常加载,导致页面404,可以修改启动类如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| @SpringBootApplication public class Application extends SpringBootServletInitializer {
public static void main(String[] args) { new SpringApplicationBuilder() .sources(Application.class) .bannerMode(Banner.Mode.OFF) .run(); }
@Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return super.configure(builder.sources(Application.class)); }
@Bean public ServletRegistrationBean registryRestServlet(DispatcherServlet dispatcherServlet) { ServletRegistrationBean<?> registrationBean = new ServletRegistrationBean<>(dispatcherServlet); registrationBean.addUrlMappings("/*"); return registrationBean; } }
|
使用了含javax.validation.api的情况
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <exclude-subsystems> <subsystem name="jpa"/> <subsystem name="logging"/> <subsystem name="jaxrs"/> </exclude-subsystems> <exclusions> <module name="javax.validation.api" /> <module name="org.hibernate.validator" /> <module name="org.slf4j" /> <module name="org.slf4j.impl" /> <module name="org.apache.httpcomponents" />
<module name="javaee.api"/> <module name="javax.faces.api"/> </exclusions> </deployment> </jboss-deployment-structure>
|