Java 如何在weblogic 12C上运行Spring引导应用程序?
如何在weblogic 12c上运行Spring引导应用程序 我的应用程序类是这样的:Java 如何在weblogic 12C上运行Spring引导应用程序?,java,weblogic,Java,Weblogic,如何在weblogic 12c上运行Spring引导应用程序 我的应用程序类是这样的: 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.
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);
}
}
现在,我在weblogic上部署应用程序
它显示了部署的成功
但是,控制台中没有Spring引导日志消息
我的控制器配置了一个映射@RequestMapping(“/home/sign\u in”)
当我访问http://localhost:7001/demo/home/sign_in
,我得到了404
控制台没有任何更改
我想在Weblogic上运行Spring启动应用程序怎么办
我需要帮助。多谢各位
附言:
这是我的pom.xml
文件的一部分:
<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>
4.0.0
com.smember
网站
战争
0.0.1-快照
网站Maven Webapp
http://maven.apache.org
org.springframework.boot
spring启动程序父级
1.4.2.1发布
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧启动机tomcat
...
...
网站
Weblogic需要WAR软件包。
您应该通过修改pom.xml将打包更改为WAR而不是JAR。在Web\u INF中添加Weblogic.xml和dispatcher servlet[empty]。 同样对于数据源配置,在weblogic中定义它并在此处使用JNDI名称[见下文] 在application.properties中 spring.datasource.jndi name=xyz jndi name 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://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.1</wls:weblogic-version>
<wls:context-root>bh</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:package-name>javax.persistence.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>
12.1.1
波黑
org.slf4j*
org.springframework*
javax.persistence.*
您可以将应用程序打包为WAR并使用JNDI资源:我更改了我的问题,请看结尾,这是我的pom.xml
文件内容。我正在部署WAR。