J2EE deployment files(web.xml)

博客涉及应用部署、servlet、扩展等信息技术内容,还提及安全方面要点,虽未给出具体内容,但围绕这些关键信息技术领域展开探讨。
<web-app>
This file contains the configuration for a web-application.

<icon>
The icon element contains a small-icon and a large-icon element which specify the location within the web application for a small and large image used to represent the web application in a GUI tool.

<small-icon>path/to/icon.gif</small-icon>
The small-icon element contains the location within the web application of a file containing a small (16x16 pixel) icon image. The image must be either GIF or JPEG format and the filename must end with the extension of ".gif" or ".jpg".

<large-icon>path/to/icon.gif</large-icon>
The large-icon element contains the location within the web application of a file containing a large (32x32 pixel) icon image. The image must be either GIF or JPEG format and the filename must end with the extension of ".gif" or ".jpg".

 
<display-name>A friendly name</display-name>
A friendly name that describes this unit.

<description>The description</description>
A short description, use etc.

<distributable />
The distributable element, by its presence in a web application deployment descriptor, indicates that this web application is programmed appropriately to be deployed into a distributed servlet container.

<context-param>
The context-param element contains the declaration of a web application's servlet context initialization parameters. There are two special kinds of initialization parameters for the optional cases where the parameter is used to obtain the JNDI name of an EJB or a data source for a subsequent look up. These are indicated by an context-param element together with an accompanying ejb-ref or resource-ref element with matching name.

<param-name>theName</param-name>
The name of the configuration parameter.

<param-value>theValue</param-value>
The value of the configuration parameter.

 
<servlet>
The servlet element contains the declarative data of a servlet. If a jsp-file is specified and the load-on-startup element is present, then the JSP should be precompiled and loaded.

<icon>
The icon element contains a small-icon and a large-icon element which specify the location within the web application for a small and large image used to represent the web application in a GUI tool.

<small-icon>path/to/icon.gif</small-icon>
The small-icon element contains the location within the web application of a file containing a small (16x16 pixel) icon image. The image must be either GIF or JPEG format and the filename must end with the extension of ".gif" or ".jpg".

<large-icon>path/to/icon.gif</large-icon>
The large-icon element contains the location within the web application of a file containing a large (32x32 pixel) icon image. The image must be either GIF or JPEG format and the filename must end with the extension of ".gif" or ".jpg".

 
<servlet-name>servletname</servlet-name>
The canonical name of the servlet.

<display-name>A friendly name</display-name>
A friendly name that describes this unit.

<description>The description</description>
A short description, use etc.

<servlet-class>com.company.servlet.DummyServlet</servlet-class>
The class name of a servlet.

<jsp-file>jsp/file/name.jsp</jsp-file>
The path to a JSP file within the web application.

<init-param>
Contains a name/value pair initialization param.

<param-name>theName</param-name>
The name of the configuration parameter.

<param-value>theValue</param-value>
The value of the configuration parameter.

 
<load-on-startup>priorityNumber</load-on-startup>
Indicates that this servlet should be loaded on startup. The optional contents of these element must be an integer indicating the order in which the servlet should be loaded.

<security-role-ref>
The security-role-ref element contains the declaration of a security role reference in the servlet's code. The contents of the role-name element is that of the String used in the servlet code to specify a role. The role-link element specifies that this coded role should be linked to a role described by the security-role element.

<description>The description</description>
A short description, use etc.

<role-name>myRole</role-name>
Defines a role name that the developer can use. The deployer maps a set of users and groups to the role name at deployment time.

<role-link>realname</role-link>
The role-link element is used to link a security role reference to a defined security role. The role-link element must contain the name of one of the security roles defined in the security-role elements.

 
 
<servlet-mapping>
Defines a mapping between a servlet and a url pattern.

<servlet-name>servletname</servlet-name>
The canonical name of the servlet.

<url-pattern>/*.thePattern</url-pattern>
The url pattern of the mapping.

 
<session-config>
Defines the session parameters for this web application.

<session-timeout>session-timeout</session-timeout>
Defines the default session timeout interval for all sessions created in this web application. The default units are measured in minutes.

 
<mime-mapping>
Defines a mapping between and extension and a mime type.

<extension>.txt</extension>
An extension. example: ".txt".

<mime-type>text/plain</mime-type>
A defined mime type. example: "text/plain".

 
<welcome-file-list>
An ordered list of welcome files.

<welcome-file>index.html</welcome-file>
A welcome file, this file will be served to the user for incoming requests without a file specified (specifying a directory) if it exists. Examples are: index.html, default.jsp, other.file.

 
<error-page>
Contains a mapping between an error code or exception type to the path of a resource in the web application.

<error-code>theErrorCodeNumber</error-code>
The HTTP error code, ex: 404.

<exception-type>java.exception.TypeOfException</exception-type>
A Java exception type.

<location>path/to/resource</location>
The location of the resource in the web application.

 
<resource-ref>
The optional resource-ref element contains a declaration of a Web Application's reference to an external resource. An context-param with the same name must be present whose value will be the JNDI data source. The context-param's value may be specified at deployment time.

<description>The description</description>
A short description, use etc.

<res-ref-name>theContextParam</res-ref-name>
Specifies the name of the resource factory reference name. This value is the name of the context-param whose value contains the JNDI name of the data source.

<res-type>com.the.TypeOfResource</res-type>
Specifies the (Java class) type of the data source.

<res-auth>CONTAINER|SERVLET</res-auth>
The res-auth element indicates whether the application component code performs resource signon programmatically or whether the container signs onto the resource based on the principle mapping information supplied by the deployer. Must be CONTAINER or SERVLET.

 
<security-constraint>
Used to associate security constraints with one or more web resource collections.

<web-resource-collection>
Used to identify a subset of the resources and HTTP methods on those resources within a web application to which a security constraint applies.

<web-resource-name>The resource name</web-resource-name>
The name of this web resource collection.

<description>The description</description>
A short description, use etc.

<url-pattern>/*.thePattern</url-pattern>
The url pattern of the mapping.

<http-method>METHOD</http-method>
A HTTP method (GET | POST |...).

 
<auth-constraint>
Indicates the user roles that should be permitted access to this resource collection as well as the authorization method to be used.

<description>The description</description>
A short description, use etc.

<role-name>myRole</role-name>
Defines a role name that the developer can use. The deployer maps a set of users and groups to the role name at deployment time.

 
<user-data-constraint>
Used to indicate how data communicated between the client and container should be protected.

<description>The description</description>
A short description, use etc.

<transport-guarantee>NONE/INTEGRAL/CONFIDENTIAL</transport-guarantee>
The transport-guarantee element specifies that the communication between client and server should be NONE, INTEGRAL, or CONFIDENTIAL.

 
 
<login-config>
The login-config element is used to configure the authentication method that should be used, the realm name that should be used for this application, and the attributes that are needed by the form login mechanism.

<auth-method>BASIC/DIGEST/FORM/CLIENT-CERT</auth-method>
The auth-method element is used to configure the authentication mechanism for the web application. As a prerequisite to gaining access to any web resources which are protected by an authorization constraint, a user must have authenticated using the configured mechanism. Legal values for this element are "BASIC", "DIGEST", "FORM", or "CLIENT-CERT".

<realm-name>Name Of Realm</realm-name>
The realm name element specifies the realm name to use in HTTP Basic authorization.

<form-login-config>
The form-login-config element specifies the login and error pages that should be used in form based login. If form based authentication is not used, these elements are ignored.

<form-login-page>path/to/loginpage.jsp</form-login-page>
Defines the location in the web app where the page that is used for login can be found.

<form-error-page>path/to/errorpage.jsp</form-error-page>
Defines the location in the web app where the error page that is displayed when login is not successful can be found.

 
 
<security-role>
The security-role element contains the declaration of a security role which is used in the security-constraints placed on the web application.

<description>The description</description>
A short description, use etc.

<role-name>myRole</role-name>
Defines a role name that the developer can use. The deployer maps a set of users and groups to the role name at deployment time.

 
<env-entry>
The env-entry element contains the declaration of an application's environment entry. This element is required to be honored on in J2EE compliant servlet containers.

<description>The description</description>
A short description, use etc.

<env-entry-name>nameOfEntry</env-entry-name>
The env-entry-name contains the name of an application's environment entry.

<env-entry-value>value</env-entry-value>
The env-entry-value element contains the value of an application's environment entry.

<env-entry-type>java.lang.String</env-entry-type>
The env-entry-type element contains the fully qualified Java type of the environment entry value that is expected by the application code. The following are the legal values of env-entry-type: java.lang.Boolean, java.lang.String, java.lang.Integer, java.lang.Double, java.lang.Float.

 
<ejb-ref>
Used in conjunction with a matching context-param of the same name to indicate that this parameter will be used to obtain the JNDI name of an EJB.

<description>The description</description>
A short description, use etc.

<ejb-ref-name>nameOfEJB</ejb-ref-name>
Contains the name of an EJB reference. This name must match an context-param name.

<ejb-ref-type>com.type.OfEJBBean</ejb-ref-type>
Contains the expected java class type of the referenced EJB.

<home>com.type.OfEJBHome</home>
Contains the fully qualified name of the EJB's home interface.

<remote>com.type.OfEJB</remote>
Contains the fully qualified name of the EJB's remote interface.

<ejb-link>nameOfEJB</ejb-link>
Used in the ejb-ref element to specify that an EJB reference is linked to an EJB in an encompassing J2EE application package. The value of the ejb-link element must be the ejb-name of and EJB in the J2EE application package.

 
<taglib>
Defines a taglib name in order to simplify the definition inside JSP-pages.

<taglib-uri>myTags</taglib-uri>
The uri as defined in the taglib directive in the JSP-pages.

<taglib-location>/WEB-INF/lib/mytags.jar</taglib-location>
The location of the library or a standalone TLD (relative or absolute URL).
weblogic.Deployer invoked with options: -debug -remote -verbose -noexit -name crm -targets AdminServer -adminurl t3://10.190.252.34:80 -user weblogic -undeploy [WebLogicDeploymentManagerImpl.<init>():112] : Constructing DeploymentManager for Java EE version V1_4 deployments [WebLogicDeploymentManagerImpl.getNewConnection():155] : Connecting to admin server at 10.190.252.34:80, as user weblogic [ServerConnectionImpl.getEnvironment():317] : setting environment [ServerConnectionImpl.getEnvironment():320] : getting context using t3://10.190.252.34:80 [ServerConnectionImpl.getMBeanServer():268] : Connecting to MBeanServer at service:jmx:t3://10.190.252.34:80/jndi/weblogic.management.mbeanservers.domainruntime [ServerConnectionImpl.getMBeanServer():268] : Connecting to MBeanServer at service:jmx:t3://10.190.252.34:80/jndi/weblogic.management.mbeanservers.runtime [DomainManager.resetDomain():36] : Getting new domain [DomainManager.resetDomain():39] : Using pending domain: false [MBeanCache.addNotificationListener():133] : Adding notification listener for weblogic.deploy.api.spi.deploy.mbeans.TargetCache@2e2ff723 [MBeanCache.addNotificationListener():140] : Added notification listener for weblogic.deploy.api.spi.deploy.mbeans.TargetCache@2e2ff723 [MBeanCache.addNotificationListener():133] : Adding notification listener for weblogic.deploy.api.spi.deploy.mbeans.ModuleCache@7cf6a5f9 [MBeanCache.addNotificationListener():140] : Added notification listener for weblogic.deploy.api.spi.deploy.mbeans.ModuleCache@7cf6a5f9 [ServerConnectionImpl.initialize():193] : Connected to WLS domain: smecs [ServerConnectionImpl.init():183] : Initializing ServerConnection : weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl@3ed242a4 [BasicOperation.dumpTmids():811] : Incoming tmids: [BasicOperation.dumpTmids():813] : {Target=AdminServer, WebLogicTargetType=server, Name=crm}, targeted=true [BasicOperation.deriveAppName():143] : appname established as: crm <Jul 17, 2025 8:25:55 AM CST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating undeploy operation for application, crm [archive: null], to AdminServer .> [BasicOperation.dumpTmids():811] : Incoming tmids: [BasicOperation.dumpTmids():813] : {Target=AdminServer, WebLogicTargetType=server, Name=crm}, targeted=true [BasicOperation.loadGeneralOptions():718] : Delete Files:false Timeout :3600000 Targets: AdminServer ModuleTargets={} SubModuleTargets={} } Files: null Deployment Plan: null App root: null App config: null Partition: null ResourceGroup: null Deployment Options: {isRetireGracefully=true,isGracefulProductionToAdmin=false,isGracefulIgnoreSessions=false,rmiGracePeriod=-1,retireTimeoutSecs=-1,undeployAllVersions=false,archiveVersion=null,planVersion=null,isLibrary=false,libSpecVersion=null,libImplVersion=null,stageMode=null,clusterTimeout=3600000,altDD=null,altWlsDD=null,name=crm,securityModel=null,securityValidationEnabled=false,versionIdentifier=null,isTestMode=false,forceUndeployTimeout=0,defaultSubmoduleTargets=true,timeout=0,deploymentPrincipalName=null,useExpiredLock=false,specifiedTargetsOnly=false,partition=null,resourceGroup=null,resourceGroupTemplate=null,uploadPath=null,specifiedModules=[],removePlanOverride=false,} [BasicOperation.execute():517] : Initiating undeploy operation for app, crm, on targets: [BasicOperation.execute():519] : AdminServer weblogic.management.ManagementException: [Deployer:149001]No application named "crm" exists for operation "undeploy". at weblogic.deploy.internal.adminserver.operations.OperationHelper.assertAppIsNonNull(OperationHelper.java:968) at weblogic.deploy.internal.adminserver.operations.RemoveOperation.updateConfiguration(RemoveOperation.java:191) at weblogic.deploy.internal.adminserver.operations.AbstractOperation.updateConfigurationAndInitializeDeployment(AbstractOperation.java:478) at weblogic.deploy.internal.adminserver.operations.AbstractOperation.execute(AbstractOperation.java:301) at weblogic.deploy.internal.adminserver.operations.RemoveOperation.execute(RemoveOperation.java:84) at weblogic.management.deploy.internal.DeployerRuntimeImpl$2.run(DeployerRuntimeImpl.java:1034) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:344) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:137) at weblogic.management.deploy.internal.DeployerRuntimeImpl.performDeployerActions(DeployerRuntimeImpl.java:1028) at weblogic.management.deploy.internal.DeployerRuntimeImpl.undeploy(DeployerRuntimeImpl.java:513) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at weblogic.management.jmx.modelmbean.WLSModelMBean.invoke(WLSModelMBean.java:532) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$21.run(WLSMBeanServerInterceptorBase.java:589) at java.security.AccessController.doPrivileged(Native Method)这是建构的什么报错,和application.xml有关系吗
07-18
at weblogic.management.mbeanservers.domainruntime.internal.FederatedMBeanServerInterceptor.invoke(FederatedMBeanServerInterceptor.java:355) at weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase$21.run(WLSMBeanServerInterceptorBase.java:589) at java.security.AccessController.doPrivileged(Native Method) at weblogic.management.jmx.mbeanserver.WLSMBeanServerInterceptorBase.invoke(WLSMBeanServerInterceptorBase.java:587) at weblogic.management.mbeanservers.internal.CallerPartitionContextInterceptor.invoke(CallerPartitionContextInterceptor.java:217) at weblogic.management.jmx.mbeanserver.WLSMBeanServer.invoke(WLSMBeanServer.java:327) at weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$11$1.run(JMXConnectorSubjectForwarder.java:655) at java.security.AccessController.doPrivileged(Native Method) at weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder$11.run(JMXConnectorSubjectForwarder.java:653) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:386) at weblogic.management.mbeanservers.internal.JMXConnectorSubjectForwarder.invoke(JMXConnectorSubjectForwarder.java:646) at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) at java.security.AccessController.doPrivileged(Native Method) at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408) at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) at javax.management.remote.rmi.RMIConnectionImpl_WLSkel.invoke(Unknown Source) at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:645) at weblogic.rmi.internal.BasicServerRef$2.run(BasicServerRef.java:534) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:386) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:163) at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:531) at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:138) at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352) at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337) at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57) at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41) at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:655) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:420) at weblogic.work.ExecuteThread.run(ExecuteThread.java:360) Unexpected Error Initializing Deployer: weblogic.management.ManagementException: [Deployer:149001]No application named "crm" exists for operation "undeploy". ------------------------------------ ARTIFACT DEPLOYMENT ------------------------------------------------ weblogic.Deployer invoked with options: -debug -stage -remote -verbose -upload -name crm -source /root/.jenkins/workspace/TEST_FN_CRM/dist/crm.war -targets AdminServer -adminurl t3://10.190.252.34:80 -user weblogic -deploy [WebLogicDeploymentManagerImpl.<init>():112] : Constructing DeploymentManager for Java EE version V1_4 deployments [WebLogicDeploymentManagerImpl.getNewConnection():155] : Connecting to admin server at 10.190.252.34:80, as user weblogic [ServerConnectionImpl.getEnvironment():317] : setting environment [ServerConnectionImpl.getEnvironment():320] : getting context using t3://10.190.252.34:80 [ServerConnectionImpl.getMBeanServer():268] : Connecting to MBeanServer at service:jmx:t3://10.190.252.34:80/jndi/weblogic.management.mbeanservers.domainruntime [ServerConnectionImpl.getMBeanServer():268] : Connecting to MBeanServer at service:jmx:t3://10.190.252.34:80/jndi/weblogic.management.mbeanservers.runtime [DomainManager.resetDomain():36] : Getting new domain [DomainManager.resetDomain():39] : Using pending domain: false [MBeanCache.addNotificationListener():133] : Adding notification listener for weblogic.deploy.api.spi.deploy.mbeans.TargetCache@2e2ff723 [MBeanCache.addNotificationListener():140] : Added notification listener for weblogic.deploy.api.spi.deploy.mbeans.TargetCache@2e2ff723 [MBeanCache.addNotificationListener():133] : Adding notification listener for weblogic.deploy.api.spi.deploy.mbeans.ModuleCache@7cf6a5f9 [MBeanCache.addNotificationListener():140] : Added notification listener for weblogic.deploy.api.spi.deploy.mbeans.ModuleCache@7cf6a5f9 [ServerConnectionImpl.initialize():193] : Connected to WLS domain: smecs [ServerConnectionImpl.setRemote():514] : Running in remote mode [ServerConnectionImpl.init():183] : Initializing ServerConnection : weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl@3ed242a4 [BasicOperation.dumpTmids():811] : Incoming tmids: [BasicOperation.dumpTmids():813] : {Target=AdminServer, WebLogicTargetType=server, Name=crm}, targeted=true [BasicOperation.deriveAppName():143] : appname established as: crm <Jul 17, 2025 8:25:59 AM CST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, crm [archive: /root/.jenkins/workspace/TEST_FN_CRM/dist/crm.war], to AdminServer .> [BasicOperation.dumpTmids():811] : Incoming tmids: [BasicOperation.dumpTmids():813] : {Target=AdminServer, WebLogicTargetType=server, Name=crm}, targeted=true [BasicOperation.loadGeneralOptions():718] : Delete Files:false Timeout :3600000 Targets: AdminServer ModuleTargets={} SubModuleTargets={} } Files: null Deployment Plan: null App root: /tmp/root/./config/deployments/crm App config: /tmp/root/./config/deployments/crm/plan Partition: null ResourceGroup: null Deployment Options: {isRetireGracefully=true,isGracefulProductionToAdmin=false,isGracefulIgnoreSessions=false,rmiGracePeriod=-1,retireTimeoutSecs=-1,undeployAllVersions=false,archiveVersion=null,planVersion=null,isLibrary=false,libSpecVersion=null,libImplVersion=null,stageMode=stage,clusterTimeout=3600000,altDD=null,altWlsDD=null,name=crm,securityModel=null,securityValidationEnabled=false,versionIdentifier=null,isTestMode=false,forceUndeployTimeout=0,defaultSubmoduleTargets=true,timeout=0,deploymentPrincipalName=null,useExpiredLock=false,specifiedTargetsOnly=false,partition=null,resourceGroup=null,resourceGroupTemplate=null,uploadPath=null,specifiedModules=[],removePlanOverride=false,} 发服务器报错这是application.xml配置的问题吗?
07-18
### 详解 `jboss-deployment-structure.xml` 文件的作用与配置 `jboss-deployment-structure.xml` 是 JBoss EAP 或 WildFly 等基于 JBoss Modules 架构的应用服务器中用于控制模块依赖关系和类加载行为的重要配置文件。该文件允许开发者在不修改 `MANIFEST.MF` 和 `jboss-web.xml` 的前提下,精确控制模块依赖、隐藏某些类路径资源、覆盖默认模块版本等,从而避免类冲突和依赖管理混乱的问题。 #### 模块依赖管理 在 JBoss 中,模块(Module)是组织类和资源的基本单位,每个模块都有一个唯一的名称和版本。通过 `jboss-deployment-structure.xml` 可以显式声明部署单元(如 WAR、EAR)所需的模块依赖。例如,若应用依赖特定版本的 `org.hibernate` 模块,可在配置文件中添加如下内容: ```xml <jboss-deployment-structure> <deployment> <dependencies> <module name="org.hibernate" slot="main" /> </dependencies> </deployment> </jboss-deployment-structure> ``` 此配置确保部署的应用程序使用指定模块,而不是服务器默认提供的版本,避免因版本不一致导致的运行时错误。 #### 隐藏服务器提供的模块 某些情况下,应用可能自带某些库(如日志框架、JPA 提供商等),不希望使用服务器提供的模块。此时可以使用 `<exclusions>` 标签排除特定模块,防止其被自动引入: ```xml <dependencies> <module name="org.apache.log4j" /> <exclusions> <module name="org.jboss.logging" /> </exclusions> </dependencies> ``` 该配置会阻止 JBoss 自动加载 `org.jboss.logging` 模块,确保应用使用其自带的日志实现。 #### 控制子部署的类加载行为 对于 EAR 包中的多个子部署(如多个 WAR 或 EJB JAR),可以通过 `<sub-deployment>` 标签分别控制其类加载策略。例如,可以为每个子部署设置独立的类加载器,防止类冲突: ```xml <sub-deployments-isolated>true</sub-deployments-isolated> ``` 此配置确保每个子部署使用独立的类加载器,避免共享类导致的冲突问题。 #### 覆盖默认模块版本 JBoss 提供了多个版本的模块供部署使用,若需使用非默认版本的模块,可在 `<module>` 标签中指定 `slot` 属性。例如,使用 `org.jboss.as.web` 的 `1.1` 版本而非默认的 `main` 版本: ```xml <module name="org.jboss.as.web" slot="1.1" /> ``` 该配置确保部署时加载指定版本的模块,避免因版本差异引发的兼容性问题。 #### 示例完整配置 以下是一个典型的 `jboss-deployment-structure.xml` 文件示例,展示了模块依赖、排除和子部署隔离的配置方式: ```xml <jboss-deployment-structure> <deployment> <sub-deployments-isolated>true</sub-deployments-isolated> <dependencies> <module name="org.hibernate" slot="main" /> <module name="org.apache.log4j" /> <exclusions> <module name="org.jboss.logging" /> </exclusions> </dependencies> </deployment> </jboss-deployment-structure> ``` 此配置适用于需要使用自定义 Hibernate 和 Log4j 实现,同时避免使用 JBoss 提供的 `org.jboss.logging` 模块的场景。 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值