У меня есть рабочий проект, разработанный с использованием весеннего ботинка, безопасности весны и весенних данных с Maven.Как интегрировать Spring boot с контейнером сервлета 3.0 и заставить его работать на сервере WebSphere 8.5.5?
Как отдельный класс, работающий нормально. WAR в Tomcat также отлично работает. Я создал EAR из WAR с Maven и развернутый в WAS 8.5.5 не работает.
Автономный Java-класс, который отлично справляется со встроенным Tomcat также с внешним Tomcat 7. То же самое не удается начать с websphere, не уверен в какой-либо другой конфигурации, которую мне не хватает?
package com.marsh.forms;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@Configuration
@EnableWebMvc
@ComponentScan
@EnableAutoConfiguration
@EnableConfigurationProperties
public class FormsRestApplication2 extends SpringBootServletInitializer {
public static void main(String[] args) throws Exception {
ApplicationContext ctx = SpringApplication.run(
FormsRestApplication2.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<FormsRestApplication2> applicationClass = FormsRestApplication2.class;
@Bean
// Magic entry
public DispatcherServlet dispatcherServlet() {
DispatcherServlet ds = new DispatcherServlet();
ds.setThrowExceptionIfNoHandlerFound(true);
return ds;
}
}
ВОЙНА pom.xml
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.marsh</groupId>
<artifactId>testparent1</artifactId>
<version>0.1</version>
</parent>
<groupId>com.marsh</groupId>
<artifactId>testwar1</artifactId>
<version>0.1</version>
<packaging>war</packaging>
<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>
<exclusion>
<artifactId>tomcat-embed-el</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
<exclusion><groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId></exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
**<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency> -->**
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<start-class>com.marsh.forms.FormsRestApplication2</start-class> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.7</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Ignore-Scanning-Archives>spring-boot-starter-data-rest-1.3.0.M5.jar, hibernate-core-4.3.11.Final.jar</Ignore-Scanning-Archives>
<Ignore-Scanning-Packages>org.springframework.data.rest.core, org.hibernate,javax.persistence </Ignore-Scanning-Packages>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
<finalName>testwar1</finalName>
</build>
<organization>
<name>marsh</name>
<url>www.marsh.com</url>
</organization>
<scm>
<developerConnection>szdasd</developerConnection>
</scm>
</project>
уха pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.marsh</groupId>
<artifactId>testparent1</artifactId>
<version>0.1</version>
</parent>
<artifactId>testear1</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com.marsh</groupId>
<artifactId>testwar1</artifactId>
<version>0.1</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<skinnyWars>true</skinnyWars>
<defaultJavaBundleDir>lib</defaultJavaBundleDir>
<modules>
<webModule>
<groupId>com.marsh</groupId>
<artifactId>testwar1</artifactId>
<contextRoot>/forms</contextRoot>
</webModule>
</modules>
<generateApplicationXml>true</generateApplicationXml>
</configuration>
</plugin>
</plugins>
<finalName>forms</finalName>
</build>
</project>
родитель pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.marsh</groupId>
<artifactId>testparent1</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- <version>1.2.7.RELEASE</version> -->
<version>1.3.0.M5</version>
<relativePath>/</relativePath>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.3.0.M5</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<!-- <module>testwar</module> <module>testear</module> -->
<module>testwar1</module>
<module>testear1</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<!-- <version>3.1</version> -->
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
уха GE и я вижу, что надлежащее обновление в application.xml было проектом с корнем контекста. Война также генерируется отлично с помощью классов и lib metaInf info.
Manifest-Version: 1.0
Implementation-Vendor: xxx
Implementation-Title: testwar1
Implementation-Version: 0.1
Implementation-Vendor-Id: com.marsh
Ignore-Scanning-Packages: org.springframework.data.rest.core, org.hibe
rnate,javax.persistence
Built-By: abc
Build-Jdk: 1.7.0_80
Ignore-Scanning-Archives: spring-boot-starter-data-rest-1.3.0.M5.jar,
hibernate-core-4.3.11.Final.jar
Created-By: Apache Maven 3.0.4
Archiver-Version: Plexus Archiver
Пара вопросов, которые я заметил:
этот вопрос EAR развертывания в сервере, но не WAR, и я не вижу, либо весной загрузки стартера или мои классы получают загружены или публикацию моей пружинный отдых данные URL-адрес:
[11/5/15 18:24:46:088 EST] 00000070 ApplicationMg A WSVR0200I: Starting application: testear1 [11/5/15 18:24:46:088 EST] 00000070 ApplicationMg A WSVR0204I: Application: testear1 Application build level: Unknown [11/5/15 18:24:48:260 EST] 00000070 webapp I com.ibm.ws.webcontainer.webapp.WebGroupImpl WebGroup SRVE0169I: Loading Web Module: Archetype Created Web Application. [11/5/15 18:24:48:397 EST] 00000070 WASSessionCor I SessionContextRegistry getSessionContext SESN0176I: Will create a new session context for application key default_host/forms [11/5/15 18:25:20:583 EST] 00000070 webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [testear1#testwar1-0.1.war]:.No Spring WebApplicationInitializer types detected on classpath [11/5/15 18:25:20:583 EST] 00000070 webcontainer I com.ibm.ws.webcontainer.VirtualHostImpl addWebApplication SRVE0250I: Web Module Archetype Created Web Application has been bound to default_host[*:9081,*:80,*:9444,*:5063,*:5062,*:443]. [11/5/15 18:25:20:640 EST] 00000070 ApplicationMg A WSVR0221I: Application started: testear1 [11/5/15 18:25:20:640 EST] 00000070 CompositionUn A WSVR0191I: Composition unit WebSphere:cuname=testear1 in BLA WebSphere:blaname=testear1 started.
Это может быть из-за несовпадение версии, но я использую jDK7 во всех компиляторах, выполнении и 8.5.5 работаю в JDK7.
[11/5/15 18:23:59:185 EST] 00000072 visitor W com.ibm.ws.amm.scan.util.AnnotationInfoDefaultVisitor visitAnnotation [ [email protected] ] for method [ [email protected] (org.springframework.data.rest.core.annotation.RepositoryRestResource.collectionResourceDescription) ] Name [ null ] Description [ Lorg/springframework/data/rest/core/annotation/Description; ] Call in violation of protocol [11/5/15 18:23:59:196 EST] 00000072 visitor W com.ibm.ws.amm.scan.util.AnnotationInfoDefaultVisitor visitAnnotation [ [email protected] ] for method [ [email protected] (org.springframework.data.rest.core.annotation.RepositoryRestResource.itemResourceDescription) ] Name [ null ] Description [ Lorg/springframework/data/rest/core/annotation/Description; ] Call in violation of protocol
Я использовал последнюю версию весной загрузки для "@ControllerAdvice (basePackageClasses = RepositoryRestExceptionHandler.class)" класса требуется.