SpringBoot部署到WAS上的问题小结

来源:互联网 发布:算法精解:c语言描述pdf 编辑:程序博客网 时间:2024/05/17 06:43

省略桃花。。。仅做记录
采用WAS版本为8.5.5.9,PS:此版本以下版本不能良好的支持Servlet3.0的注解功能,而SpringBoot完全取消了web.xml的配置,采用注解方式。
采用JDK1.6,PS:从1.8降到1.7再到1.6,前后花费长时间发现1.6版本比较稳定,WAS的支持比较好。
在开发过程中遇到的问题如下:
1)采用jdk1.8时,由于服务器版本WAS8.0.0.9的JDK版本为1.6,出现部署后404的问题“WebSphere Application Server:Error 404: java.io.FileNotFoundException: SRVE0190E: File not found:”,起初以为是WAS不能支持注解形式的Servlet调起Spring,在网上查询解决方案得到:去掉SpringBootServletInitializer接口实现,重新加入web.xml方式。出现JDK版本问题,遂降低至jdk1.6,期间出现spring-boot-starter-tomcat版本由8降至7.0.59,此种方式可行;
2)但是采用web.xml方式完全背离了SpringBoot的本意,故重新找到一台WAS8.5.5.9的机器进行SpringBootServletInitializer方式启动,出现 com.ibm.ws.ecs.internal.scan.context.impl.ScannerContextImpl scanJAR unable to open input stream for resource org/apache/ibatis/javassist/SerializedProxy.class in archive WEB-INF/lib/mybatis-3.4.0.jar 的问题,查询解决方案:https://github.com/mybatis/mybatis-3/issues/706#issuecomment-227731860 获知:mybatis3.4.0下的此类与SpringBoot不兼容,改为 3.4.1即可解决

<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>        <dependency>            <groupId>org.springframework.boot</groupId>            <artifactId>spring-boot-starter-tomcat</artifactId>            <scope>provided</scope>        </dependency>        <dependency>            <groupId>org.mybatis.spring.boot</groupId>            <artifactId>mybatis-spring-boot-starter</artifactId>            <version>${mybatis.spring.version}</version>            <exclusions>                <exclusion>                    <groupId>org.mybatis</groupId>                    <artifactId>mybatis</artifactId>                </exclusion>            </exclusions>        </dependency>        <dependency>            <groupId>org.mybatis</groupId>            <artifactId>mybatis</artifactId>            <version>3.4.1</version>        </dependency>

Mybatis版本兼容问题原因:mybatis-spring-boot-starter为高人贡献,其中有个类涉及到注入方式为构造器方式注入,在Spring中采用@Autowired方式注入时,会得到多个注入类,导致错误,没有明白为何会采用构造器方式注入。springBoot提供了此种问题的解决方式:Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed。即采用@Primary注解在多个构造时选取特定的一个。而某高人修改了此类的构造器注入方式为注解注入,也解决了这个问题。

0 0