gpt4 book ai didi

java - jboss 上的 spring boot 应用程序未运行

转载 作者:行者123 更新时间:2023-12-01 09:33:59 26 4
gpt4 key购买 nike

我有以下 Maven 配置

<?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.project</groupId>
<artifactId>project-service</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
<jdk.version>1.8</jdk.version>
<name>project-domain</name>
<start-class>com.wearable.service.WearableServiceApplication</start-class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<url>http://maven.apache.org</url>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.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>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons.logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

这是我的应用程序类

package com.project.service;

import lombok.extern.slf4j.Slf4j;
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.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
@Slf4j
public class ProjectServiceApplication extends SpringBootServletInitializer {
private static Class<ProjectServiceApplication> app = WearableServiceApplication.class;

public static void main(String[] args) throws Exception {
System.out.println("------------------------------------------------");
SpringApplication.run(app, args);
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(app);
}
}

我期望的是,当我构建这场 war 并将其部署在 jboss 上时,我应该在控制台中看到“--------------------”消息,但是我没有看到任何这些。我也没有看到任何错误。

我遇到的主要问题是我的调度程序无法工作。调度程序类位于 com.project.service.scheduler 包中。这是代码。我不关心 main/config 方法,但我想知道为什么调度程序不起作用。

@Component
public class DataScheduler {

@Scheduled(fixedDelay = 500, initialDelay = 500)
public void scheduler() {
System.out.println("--------------");
}
}

这是我的 jboss 输出

/Users/username/Documents/dev/wildfly-9.0.2.Final/bin/standalone.sh
/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java -classpath "/Applications/IntelliJ IDEA 14.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA 14.app/Contents/lib/util.jar" -Dfile.encoding=UTF-8 com.intellij.rt.execution.CommandLineWrapper /private/var/folders/17/v3pnl0n532q_fvg8_8m3t2d00000gn/T/classpath0.tmp com.intellij.javaee.oss.process.JavaeeProcess 63982 com.intellij.javaee.oss.jboss.agent.JBoss71Agent
=========================================================================
[2016-08-26 01:02:44,939] Artifact project-service:war: Server is not connected. Deploy is not available.

Detected server admin port: 9990
JBoss Bootstrap Environment
Detected server http port: 8080

JBOSS_HOME: /Users/username/Documents/dev/wildfly-9.0.2.Final

JAVA: /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java

JAVA_OPTS: -server -XX:+UseCompressedOops -server -XX:+UseCompressedOops -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

01:02:44,922 INFO [org.jboss.modules] (main) JBoss Modules version 1.4.3.Final
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
01:02:45,091 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
01:02:45,157 INFO [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) starting
01:02:45,836 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 6) WFLYCTL0028: Attribute 'job-repository-type' in the resource at address '/subsystem=batch' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
01:02:45,841 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 18) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=ExampleDS' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
01:02:45,848 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found fitbit-rest-api-1.0-SNAPSHOT.war in deployment directory. To trigger deployment create a file called fitbit-rest-api-1.0-SNAPSHOT.war.dodeploy
01:02:45,855 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
01:02:45,870 INFO [org.xnio] (MSC service thread 1-3) XNIO version 3.3.1.Final
01:02:45,876 INFO [org.xnio.nio] (MSC service thread 1-3) XNIO NIO Implementation Version 3.3.1.Final
01:02:45,903 INFO [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem
01:02:45,903 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
01:02:45,907 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors
01:02:45,910 INFO [org.jboss.as.security] (MSC service thread 1-6) WFLYSEC0001: Current PicketBox version=4.9.2.Final
01:02:45,921 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem.
01:02:45,923 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main]
01:02:45,948 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem
01:02:45,954 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension
01:02:45,963 INFO [org.jboss.remoting] (MSC service thread 1-3) JBoss Remoting version 4.0.9.Final
01:02:45,967 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
01:02:45,969 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0003: Undertow 1.2.9.Final starting
01:02:45,969 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0003: Undertow 1.2.9.Final starting
01:02:45,986 INFO [org.jboss.as.connector] (MSC service thread 1-7) WFLYJCA0009: Starting JCA Subsystem (IronJacamar 1.2.5.Final)
01:02:45,995 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0018: Started Driver service with driver-name = h2
01:02:46,070 INFO [org.jboss.as.naming] (MSC service thread 1-5) WFLYNAM0003: Starting Naming Service
01:02:46,070 INFO [org.jboss.as.mail.extension] (MSC service thread 1-6) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
01:02:46,135 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path /Users/username/Documents/dev/wildfly-9.0.2.Final/welcome-content
01:02:46,157 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0012: Started server default-server.
01:02:46,172 INFO [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0018: Host default-host starting
01:02:46,220 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTP listener default listening on /127.0.0.1:8080
01:02:46,315 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
01:02:46,395 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) WFLYDS0013: Started FileSystemDeploymentService for directory /Users/username/Documents/dev/wildfly-9.0.2.Final/standalone/deployments
01:02:46,473 INFO [org.jboss.ws.common.management] (MSC service thread 1-7) JBWS022052: Starting JBoss Web Services - Stack CXF Server 5.0.0.Final
01:02:46,592 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
01:02:46,593 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
01:02:46,593 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) started in 1915ms - Started 203 of 379 services (210 services are lazy, passive or on-demand)
Connected to server
[2016-08-26 01:02:46,954] Artifact project-service:war: Artifact is being deployed, please wait...
01:02:47,055 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "project-service-1.0-SNAPSHOT.war" (runtime-name: "project-service-1.0-SNAPSHOT.war")
01:02:47,826 WARN [org.jboss.as.ee] (MSC service thread 1-7) WFLYEE0007: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
01:02:47,827 WARN [org.jboss.as.ee] (MSC service thread 1-7) WFLYEE0007: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
01:02:47,958 INFO [io.undertow.servlet] (ServerService Thread Pool -- 22) 2 Spring WebApplicationInitiusernamezers detected on classpath
01:02:48,496 INFO [stdout] (ServerService Thread Pool -- 22)
01:02:48,496 INFO [stdout] (ServerService Thread Pool -- 22) . ____ _ __ _ _
01:02:48,496 INFO [stdout] (ServerService Thread Pool -- 22) /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
01:02:48,497 INFO [stdout] (ServerService Thread Pool -- 22) ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
01:02:48,497 INFO [stdout] (ServerService Thread Pool -- 22) \\/ ___)| |_)| | | | | || (_| | ) ) ) )
01:02:48,497 INFO [stdout] (ServerService Thread Pool -- 22) ' |____| .__|_| |_|_| |_\__, | / / / /
01:02:48,497 INFO [stdout] (ServerService Thread Pool -- 22) =========|_|==============|___/=/_/_/_/
01:02:48,498 INFO [stdout] (ServerService Thread Pool -- 22) :: Spring Boot :: (v1.4.0.RELEASE)
01:02:48,498 INFO [stdout] (ServerService Thread Pool -- 22)
01:02:48,544 INFO [com.project.service.ProjectServiceApplication] (ServerService Thread Pool -- 22) Starting ProjectServiceApplication on muhammads-macbook-pro.local with PID 34679 (started by username in /Users/username/Documents/dev/wildfly-9.0.2.Final/bin)
01:02:48,544 INFO [com.project.service.ProjectServiceApplication] (ServerService Thread Pool -- 22) The following profiles are active: dev
01:02:48,565 INFO [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] (ServerService Thread Pool -- 22) Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7f63a29f: startup date [Fri Aug 26 01:02:48 EDT 2016]; root of context hierarchy
01:02:48,995 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (ServerService Thread Pool -- 22) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
01:02:49,008 INFO [io.undertow.servlet] (ServerService Thread Pool -- 22) Initializing Spring embedded WebApplicationContext
01:02:49,008 INFO [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 22) Root WebApplicationContext: initialization completed in 443 ms
01:02:49,325 INFO [org.springframework.boot.web.servlet.ServletRegistrationBean] (ServerService Thread Pool -- 22) Mapping servlet: 'dispatcherServlet' to [/]
01:02:49,326 INFO [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 22) Mapping filter: 'errorPageFilter' to: [/*]
01:02:49,327 INFO [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 22) Mapping filter: 'characterEncodingFilter' to: [/*]
01:02:49,327 INFO [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 22) Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
01:02:49,327 INFO [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 22) Mapping filter: 'httpPutFormContentFilter' to: [/*]
01:02:49,327 INFO [org.springframework.boot.web.servlet.FilterRegistrationBean] (ServerService Thread Pool -- 22) Mapping filter: 'requestContextFilter' to: [/*]
01:02:49,502 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter] (ServerService Thread Pool -- 22) Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7f63a29f: startup date [Fri Aug 26 01:02:48 EDT 2016]; root of context hierarchy
01:02:49,547 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 22) Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
01:02:49,548 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 22) Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
01:02:49,564 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (ServerService Thread Pool -- 22) Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
01:02:49,564 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (ServerService Thread Pool -- 22) Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
01:02:49,585 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (ServerService Thread Pool -- 22) Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
01:02:49,698 INFO [org.springframework.jmx.export.annotation.AnnotationMBeanExporter] (ServerService Thread Pool -- 22) Registering beans for JMX exposure on startup
01:02:49,711 INFO [com.project.service.ProjectServiceApplication] (ServerService Thread Pool -- 22) Started ProjectServiceApplication in 1.674 seconds (JVM running for 5.123)
01:02:49,747 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 22) Initializing Mojarra 2.2.12-jbossorg-2 20150729-1131 for context '/project-service-1.0-SNAPSHOT'
01:02:50,659 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 22) WFLYUT0021: Registered web context: /project-service-1.0-SNAPSHOT
01:02:50,671 INFO [org.jboss.as.server] (management-handler-thread - 2) WFLYSRV0010: Deployed "project-service-1.0-SNAPSHOT.war" (runtime-name : "project-service-1.0-SNAPSHOT.war")
[2016-08-26 01:02:50,681] Artifact project-service:war: Artifact is deployed successfully
[2016-08-26 01:02:50,681] Artifact project-service:war: Deploy took 3,727 milliseconds

最佳答案

当 Spring Boot 应用程序打包为 war 并部署到应用服务器时,不会调用 main 方法。而是调用上面显示的 configure 方法。

关于java - jboss 上的 spring boot 应用程序未运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39158651/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com