我开发了一个服务于rest服务的独立spring boot应用程序,我把它打包成了一个< code>jar,它运行正常。为了在生产服务器(Websphere)上发布它,我必须将它转换成一个< code>war。
我已经更新了我的<code>pom。xml添加以下行:
<properties>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>
<packaging>war</packaging>
<build>
<finalName>${artifactId}</finalName>
</build>
然后,我启动了maven净包
,我得到了war
。因此,在Tomcat服务器上发布它可以正常工作,但在Liberty上我收到了错误:
Error 404: SRVE0190E: File not found /
我还修改了我的入口点,如下所示:
@SpringBootApplication
@PropertySource("classpath:alerts.properties")
public class WebApplication extends SpringBootServletInitializer
{
// public static void main(String[] args) {
// SpringApplication.run(WebApplication.class, args);
// }
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebApplication.class);
}
}
没有成功,所以...如何在Liberty服务器上运行Spring启动战?
更新
正如@Anjum Fatima所建议的,我还添加了server.xml
中的功能。
<feature>jsp-2.3</feature>
<feature>springBoot-2.0</feature>
<feature>servlet-3.1</feature>
之前,在该文件中,我还添加了:
<library>
<file id="alerts.properties" name="${shared.resource.dir}/alerts.properties"/>
</library>
<webApplication id="alerts" location="alerts.war" name="alerts">
在wlp18\usr\shared\resources
中,我复制了属性文件。
但是我还是有同样的错误。
alert.properties
文件:
spring.datasource.url=jdbc:h2:file:~/alertsdb;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE
spring.datasource.username=admin
spring.datasource.password=mypassword
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true
spring.mvc.view.prefix: /
spring.mvc.view.suffix: .jsp
spring.messages.basename=validation
更新2
服务器快启动了,但是找不到一些文件,比如com.ibm.ws.kernel.boot.nls_1.0.22.jar
,在Liberty的lib文件夹中有文件com.ibm.ws.kernel.boot_1.0.22.jar
(没有. nls
)这是控制台输出,我缺少什么?
2020-03-18 13:44:38.950 INFO 34004 --- [ecutor-thread-4] it.mycompany.alerts.WebApplication : Started WebApplication in 10.915 seconds (JVM running for 24.544)
[WARNING ] The XML schema [web-jsptaglibrary_2_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_5.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [jsp_2_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_1_2.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_client_1_2.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-app_3_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-fragment_3_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-common_3_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_6.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [jsp_2_2.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_1_3.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_client_1_3.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-app_3_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-fragment_3_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-common_3_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_7.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_1_4.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_client_1_4.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-app_4_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-fragment_4_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-common_4_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_8.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] Failed to scan [file:/C:/lang/appserver/wlp/wlp18/lib/com.ibm.ws.kernel.boot.nls_1.0.22.jar] from classloader hierarchy
C:\lang\appserver\wlp\wlp18\lib\com.ibm.ws.kernel.boot.nls_1.0.22.jar (File not found)
谢谢你
你不需要把Spring靴罐当作一场自由战争。以下是有关如何在自由中部署Spring Boot罐的自由指南:https://openliberty.io/guides/spring-boot.html 这里有另一篇关于在自由中运行Spring Boot应用程序的精彩文章:https://developer.ibm.com/articles/modernize-and-optimize-spring-boot-applications/
如果您将应用程序打包为一个真正的war,而不是一个转换的jar文件,那么您只需要servlet
功能和dropins
文件夹。
我的< code>server.xml:
<server description="Tester">
<featureManager>
<feature>servlet-4.0</feature>
</featureManager>
<httpEndpoint host="*" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
</server>
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ibm.example</groupId>
<artifactId>SpringbootWeb</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<parent>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-app-parent</artifactId>
<version>3.2</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<packaging.type>minify,runnable</packaging.type>
</properties>
<profiles>
<profile>
<id>usr-package</id>
<properties>
<packaging.type>usr</packaging.type>
</properties>
</profile>
</profiles>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<packagingExcludes>pom.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.2</version>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>[18.0.0.1,)</version>
<type>zip</type>
</assemblyArtifact>
<serverName>${project.artifactId}Server</serverName>
<include>${packaging.type}</include>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.5.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
当您在Maven中运行包
目标时,它将创建一个war和一个jar,其中包含jar格式的自由运行时包。您可以将战争放在当前应用程序的下拉列表
文件夹中。确保Liberty<code>消息中没有其他错误。日志文件。
我在 GitHub 上的例子 - 布莱恩
您可以在https://github.com/anjumfatima90/dojo.samples.中查看一个示例Spring Boot war应用程序,它包含自由部署的步骤。我希望这能有所帮助。
更新:有两种方法可以在开放自由中部署Spring启动战争,您将其部署为普通的旧战争,不需要将springBoot-2.0功能添加到server.xml.我的github示例显示了另一种方法,您可以在server.xml中添加springBoot-2.0
功能以及中的更改。
考虑到你的方式,它是作为一个普通的旧战争部署的。斯科特克隆了你的应用程序,并在他的存储库https://github.com/scottkurz/springboot-liberty-1中添加了自由-maven-plugin
来帮助你。
工作步骤:
注意:Scott在应用程序的src/main/Resources
中添加了alerts.properties
。
我是Spring应用程序开发的新手。 如何在tomcat服务器的开发阶段运行我的应用程序。 在这里我可以看到最终部署的解决方案。每次我需要停下来重新开始时,我只需要在ui上更改一些。这让我很难受。所以你能帮我照顾她吗?? 我的pom.xml依赖是 org.springframework spring-binding 1.0.6
这里有一些在服务器运行 WSGI 应用的方式。当你正在开发一个应用,你往往不想在一个成 熟服务器上部署和运行,取而代之的是一个轻量服务器。 Werkzeug 就内置了这样一个轻量 的服务器。 在一个服务器上运行 start-myproject.py 最简单的方法如下示例: #!/usr/bin/env python # -*- coding: utf-8 -*- from werkzeug.se
我需要在2个或更多带有HTTPS的端口上运行同一台服务器。在早期的生产中,我们为服务配置了端口10500。目前,我们需要在启用SSL的情况下在443和10500上运行它。 java.lang.IllegalArgumentException:在方法名[0x160x030X010X010X000X010XFC0x030X030X810X00AC0x1B0x10`0xB80X8D0xAE0x9E0xE
问题内容: 我在CI和CD上创建了Jenkinsfile,Dockerfile,Dockerfile.test到CI和CD,在GitHub上构建了我的服务器API,我在Jenkins上构建了该构建,并且构建成功,并且我的docker在Jenkinsfile阶段也在容器上运行,我创建了用于测试和部署在服务器API上,并使用docker作为容器 我也使用docker-compose在docker上运行
我有一个在Liberty WebSphere Server 17.0.0.2上使用AngularJSP的项目,现在我必须对其进行升级。该项目需要升级到Angular 4 Liberty,我不知道如何正确地完成。 我现在尝试过的是: 使用角度 CLI 生成项目以生成分离文件夹。然后,我把这个分歧放在网络-INF上 提前感谢。
我正在为Spring引导Web服务器编写集成测试 我想使用junit-jupiter(junit5)来检查服务器是否正在使用运行,以便在服务器未运行时测试不会失败... 似乎没有任何API支持这样的操作,但是可以通过其他方式实现吗?Ping 服务器?