Build Spring Boot for Deploying on Weblogic 12c
Apr 3, 2021
Building spring boot is very simple and easy with gradle. But when deploy to Weblogic we need to know the trick.
By default, spring boot have embed Tomcat. so in gradle.build
we need to exclude Tomcat from it.
configurations {
compile.exclude module: "spring-boot-starter-tomcat"
}
The below configuration, we will tell weblogic that our context is /sample
and name it as weblogic.xml
.
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:context-root>/sample</wls:context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.slf4j.*</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>
Please save it in webapp/WEB-INF/
as we show in image below:
Then, we can run gradle build task.