【发布时间】:2020-06-24 15:26:30
【问题描述】:
我有一个 java 应用程序,它只是从另一个项目中获取一个 jar,该 jar 使用无限循环来轮询有关 AWS SQS 主题的消息。
循环在我的客户端应用程序中查找带有@subscriber 注释的方法。
我有一个 bean,它会返回一个类,该类有一个带注释的方法。 当我删除使用注释方法调用类的 bean 时,我的 tomcat 在端口上启动。当我再次添加它时,没有托管端口。
在 pom 文件中,我添加了这 2 个依赖项(以及其他一些依赖项,但这些应该是相关的)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
我的主课是这样的
@SpringBootApplication
@ComponentScan(basePackages = {"com.mypackage.reuse", "com.mypackage.sample.subscriber"})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
我启动应用程序时获得的日志
2020-03-12 14:32:56.228 INFO 2429 --- [ main] c.l.g.e.f.sample.subscriber.Application : The following profiles are active: development
2020-03-12 14:32:57.580 INFO 2429 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 1339 (http)
2020-03-12 14:32:57.586 INFO 2429 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-03-12 14:32:57.587 INFO 2429 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.29]
2020-03-12 14:32:57.650 INFO 2429 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-03-12 14:32:57.651 INFO 2429 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1363 ms
2020-03-12 14:32:58.038 INFO 2429 --- [ main] org.reflections.Reflections : Reflections took 111 ms to scan 2 urls, producing 23 keys and 53 values
之后就没有日志了,我会期待这样的结果,如果我删除循环,我会得到这样的结果。当我删除循环时,我得到如下所示的内容,但问题是我需要循环不断轮询。
Exposing 2 endpoint(s) beneath base path '/actuator'
Tomcat started on port(s): 1339 (http) with context path ''
【问题讨论】:
-
是你的属性文件吗?
-
你想要我的 applcations 属性文件吗?
标签: java spring web-services tomcat