3

How does Spring Boot application work on weblogic 12C?

 2 years ago
source link: https://www.codesd.com/item/how-does-spring-boot-application-work-on-weblogic-12c.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How does Spring Boot application work on weblogic 12C?

advertisements

How to Spring Boot app run on weblogic 12c.

My application class like this :

package com.website;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.sql.DataSource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.web.WebApplicationInitializer;

@EnableAutoConfiguration
@ComponentScan
@MapperScan("com.website.mapper")
@SpringBootApplication
public class Application extends SpringBootServletInitializer implements WebApplicationInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Application.class);
    }

    @Bean
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource dataSource() {
        return new org.apache.tomcat.jdbc.pool.DataSource();
    }

    @Bean
    public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
        SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
        sessionFactoryBean.setDataSource(dataSource());

        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        sessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mybatis/*.xml"));
        return sessionFactoryBean.getObject();
    }

    /**
     * Start
     *
     * @Created by zyj on 2016年11月28日
     * @param args
     * @Version 1.0
     */
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Now, I deploy app on weblogic.

It shows the deployment success.

However, there are no Spring Boot log messages in the console.

My controller is configured with a mapping @RequestMapping("/home/sign_in").

When i visit http://localhost:7001/demo/home/sign_in, I got 404.

Console without any changes.

I want to run Spring Boot applications on Weblogic how to do?

I need help. Thank you very much.

This is part of my pom.xml file :

<modelVersion>4.0.0</modelVersion>
<groupId>com.smember</groupId>
<artifactId>website</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>website Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.2.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
...
</dependencies>
...
<build>
    <finalName>website</finalName>
</build>


Weblogic expects WAR package. You should change your packaging to WAR instead of JAR by modifying your pom.xml.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK