- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个使用 Spring Boot、Spring Boot Security 和 Spring Data Rest 以及 Maven 开发的工作项目。
作为一个独立的类,工作得很好。 Tomcat 中的 WAR 部署也工作正常。我已经使用 Maven 从 WAR 中生成了 EAR,并部署在 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;
}
}
WAR 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>
<小时/>
ear 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>
Ear 生成成功,我可以在 application.xml 中看到有关具有上下文根的项目的正确更新。 War 也可以通过类和 lib metaInf 信息生成良好的结果。
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,我没有看到 Spring Boot Starter 或我的类被加载或发布我的 Spring Rest 数据 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 中运行的 WAS 8.5.5 中使用 jDK7。
[11/5/15 18:23:59:185 EST] 00000072 visitor W com.ibm.ws.amm.scan.util.AnnotationInfoDefaultVisitor visitAnnotation [ com.ibm.ws.amm.scan.util.InfoVisitor@572832628 ] for method [ com.ibm.ws.amm.scan.util.info.impl.MethodInfoImpl@2048932859 ( 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 [ com.ibm.ws.amm.scan.util.InfoVisitor@572832628 ] for method [ com.ibm.ws.amm.scan.util.info.impl.MethodInfoImpl@-535225858 ( org.springframework.data.rest.core.annotation.RepositoryRestResource.itemResourceDescription ) ] Name [ null ] Description [ Lorg/springframework/data/rest/core/annotation/Description; ] Call in violation of protocol
我已经使用了最新的 Spring Boot 版本来实现“@ControllerAdvice(basePackageClasses = RepositoryRestExceptionHandler.class)”类是必需的。
最佳答案
解决方案:我可以使用 servlet2.5 容器解决此问题,这意味着我已更改了 web.xml,如下所示,并按照以下线程步骤使其工作,因为我无法获得快速解决方案以使其与 WAS 5.5.5.0 中的 servlet 3.0 一起工作
https://bp3.zendesk.com/hc/en-us/articles/210443048-Running-Spring-Boot-JPA-apps-in-WebSphere-8-5-5
web.xml
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.marsh.forms.FormsRestApplication2</param-value>
</context-param>
<listener>
<listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>
</listener>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
springSecurity过滤链 org.springframework.web.filter.DelegatingFilterProxy
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>ERROR</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
由于我更改了容器版本,因此我还降低了 hibernate 和 spring boot jpa 版本来执行我的项目。
<?xml version="1.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”> 4.0.0 沼泽com 测试父级1 0.1 沼泽com 测试战1 0.1 war
<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-legacy</artifactId>
<version>1.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</exclusion>
</exclusions>
</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>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.12.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.12.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</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.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<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>
<scm>
<developerConnection>abc</developerConnection>
</scm>
Spring Boot入门类(class):
@Configuration
@EnableWebMvc
@ComponentScan
@EnableAutoConfiguration
@EnableConfigurationProperties
public class FormsRestApplication2{
public static void main(String[] args) throws Exception {
ApplicationContext ctx = SpringApplication.run(
FormsRestApplication2.class, args);
}
private static Class<FormsRestApplication2> applicationClass = FormsRestApplication2.class;
@Bean
public DispatcherServlet dispatcherServlet() {
DispatcherServlet ds = new DispatcherServlet();
ds.setThrowExceptionIfNoHandlerFound(true);
return ds;
}
}
关于java - 如何将 Spring boot 与 servlet 3.0 容器集成并使其在 Websphere 8.5.5 服务器上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33558999/
我有一个关于 Java Servlet 的问题。 假设我在 servlet 网页“somePage”上。我想登录(使用另一个 servlet,“登录”servlet)。所以我点击“somePage”上
如何将变量数组从一个 servlet 传递到另一个 servlet? 最佳答案 如果您要将当前请求传递给另一个servlet,则只需将其设置为请求属性即可。 request.setAttribute(
什么可能导致此错误? Caused by: jakarta.servlet.UnavailableException: Servlet class org.restlet.ext.servle
我的maven依赖树是这样的 我想问我maven如何解决这个冲突,有两个servlet-api.jar?提前谢谢你。 最佳答案 如果您想从 Velocity 工具中删除 servlet-api,您可以
config ProcessReg ProcessReg text HelloWorld1 public class config implements Serv
您好,我有一个关于 servlet 调用另一个 servlet 的问题 我有一个名为 Relay 的主 servlet,它将负责控制其他 servlet 用户将点击并将转发到 Relay servle
在我的 REST API 项目中,我已将 /* 映射到 RESTServlet,并且需要在同一 WAR 中托管静态内容。我更愿意将 /static/* 映射到 WAS liberty 提供的默认 se
响应映射在 Servlet 中如何工作? 每个响应如何知道清除特定 HTML 或 Handlebars 上的输出? 最佳答案 有一个 ember-java带有 Jersey REST 服务 的 git
有一个 @WebServlet(urlPatterns = "/myServlet/") .如果用户转到 myapp/myServlet/other ,我仍然希望我的 servlet 能够捕获。也就是
我正在使用 Filter 在我的所有页面中插入反点击劫持 header - 这工作正常,除了 JBoss EAP 6.3 容器管理的登录页面,这是更重要的页面之一拥有它。 登录页面根本不调用过滤器,登
我正在尝试使用 RequestDispatcher 将数据从一个 servlet 传递到另一个 servlet。这是我的调度程序代码。 String address; address = "/Java
我刚刚开始使用 Servlet,并设法让一些 Servlet 充当单独的 URL,用于填充数据库以进行一些虚拟测试。某种形式: public class Populate_ServletName ex
我是否需要同时配置app.servlet.version 和 grails.servlet.version? 前者在application.properties中,后者在BuildConfig.gro
在Myeclipse中我创建了一个名为web1的Web项目,并添加了一个名为servlet1的servlet,web.xml如下: servlet1 servlet1
这个问题在这里已经有了答案: How to run a background task in a servlet based web application? (5 个回答) 6年前关闭。 是否可以在
在我的 ManagedBean 中,如果我将范围从 @RequestScoped 更改为 @ViewScoped,我将收到以下错误堆栈。我该如何解决这个问题?不过,当我运行应用程序时,我可以在页面中看
这个问题已经有答案了: How do I execute multiple servlets in sequence? (2 个回答) 已关闭 3 年前。 我已经构建了jdbc-Servlet的代码,
我一直在徒劳地尝试实现 tomcat 9 的 jakarta servlet,而不是以前的 javax.servlet 实现(因为我的理解是 jakarta 包是前进的方向)。问题是,当我将浏览器指向
我是 Spring 新手,正在尝试使用 Maven 部署和运行我的第一个 Spring Web 应用程序。有关更多详细信息,请参阅 here (我昨天发布的一个问题): 现在,我遇到的问题是:当我尝试
我正在尝试学习如何使用 JSP。我遇到了一些毫无意义的事情,至少在我看来是这样: 当我尝试运行时: response.getWriter().println(m.getDb().printAll())
我是一名优秀的程序员,十分优秀!