weblogic部署springboot项目war包

weblogic部署SpringBoot项目详细步骤

    • 一、SpringBoot项目创建
    • 二、修改启动类
    • 三、新建web.xml和weblogic.xml
      • 1.web.xml
      • 2.weblogic.xml

环境:

IDE Eclipse Version: Photon Release (4.8.0)
weblogic 10.3.6.0
JDK jdk1.8.0_181

一、SpringBoot项目创建

pom文件如下:



	4.0.0
	com.cqapp.main
	cqapp-main
	0.0.2-SNAPSHOT
	war
	
		org.springframework.boot
		spring-boot-starter-parent
		1.5.2.RELEASE
	

	
		UTF-8
		1.6
		2.7
		com.cqapp.main.MainApplication
	

	
		
			org.springframework.boot
			spring-boot-legacy
			1.0.0.RELEASE
		

		
		
			org.springframework.boot
			spring-boot-starter-web
			
				
					org.springframework.boot
					spring-boot-starter-logging
				
			
		

		
		
			org.apache.tomcat.embed
			tomcat-embed-jasper
			provided
		

		
		
			org.springframework.boot
			spring-boot-starter-tomcat
			provided
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		

		
			org.springframework.boot
			spring-boot-devtools
		
		

		
			mysql
			mysql-connector-java
			5.1.6
		

		
			com.oracle
			ojdbc6
			11.2.0.1.0
		

		
			org.springframework
			spring-tx
			4.3.7.RELEASE
		

		
			commons-logging
			commons-logging
			1.2
			
				
					javax.servlet
					servlet-api
				
			
		

		
			commons-fileupload
			commons-fileupload
			1.3.2
		

		
			commons-io
			commons-io
			2.5
		

		
		
			junit
			junit
			4.9
			test
		
		
			javax.servlet
			servlet-api
			2.5
			provided
		

		
			org.apache.tomcat
			tomcat-coyote
			7.0.5
		
		
		
			javax.servlet
			jstl
		

		
			taglibs
			standard
			1.1.2
		

		
		
			org.mybatis
			mybatis
			3.2.7
		
		
		
			org.mybatis
			mybatis-spring
			1.2.2
		
		
		
			com.jolbox
			bonecp-spring
			0.8.0.RELEASE
		
		
			org.springframework
			spring-jdbc
		
		
			com.github.pagehelper
			pagehelper
			5.1.2
		

		
			com.google.code.gson
			gson
		

		
			org.apache.commons
			commons-lang3
			3.4
		

		
			org.webjars.bower
			echarts
			4.0.4
		

		
			org.webjars
			jquery
			3.3.1
		
		
		
			org.apache.axis
			axis
			1.4
		

		
			axis
			axis-jaxrpc
			1.4
		

		
			commons-discovery
			commons-discovery
			0.2
		
		
			wsdl4j
			wsdl4j
			1.6.3
		
		
		
			com.thoughtworks.xstream
			xstream
			1.4.10
		
		
			net.sf.json-lib
			json-lib
			2.4
			jdk15
		
		
			org.codehaus.xfire
			xfire-all
			1.2.6
			
				
					org.springframework
					spring
				
				
					activation					
					activation					
								
									
					junit					
					junit
				

			
		
	

	
		cqapp-main
		
			
				src/main/webapp
				META-INF/resources
				
					**/**
				
			
			
				src/main/resources
				false
				
					**/**
				
			
		
		
			
				org.springframework.boot
				spring-boot-maven-plugin
				1.4.2.RELEASE
			
		
	


修改打包方式为war,其中注意以下依赖的修改:


		
			org.springframework.boot
			spring-boot-starter-tomcat
			provided
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		

二、修改启动类

package com.cqapp.main;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.web.WebApplicationInitializer;
@SpringBootApplication
public class MainApplication extends SpringBootServletInitializer implements WebApplicationInitializer{
//	public class MainApplication extends SpringBootServletInitializer {	
	public static void main(String[] args) {		
		//入口运行类
		SpringApplication.run(MainApplication.class, args);
	}
	@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(MainApplication.class);
    }
	
}

三、新建web.xml和weblogic.xml

1.web.xml




 	
        contextConfigLocation
        com.cqapp.main.MainApplication
    
    
        org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener
    
 
 
    
        appServlet
        org.springframework.web.servlet.DispatcherServlet
        
            contextAttribute
            org.springframework.web.context.WebApplicationContext.ROOT
        
        1
    
 
    
        appServlet
        /
    

此处填写启动类的全类名:


        contextConfigLocation
        com.cqapp.main.MainApplication
    

2.weblogic.xml



    cqapp-main
    
        
            org.slf4j.*
            org.springframework.*
          
    
    
    	 true
    

至此,修改和添加文件已完成,将项目打包,发布至weblogic即可正常访问。

你可能感兴趣的:(weblogic部署springboot项目war包)