[英]How to make non executable library (jar) using spring boot?
I am working on an application and deploying in cloud foundry. 我正在开发应用程序并在Cloud Foundry中进行部署。 Internally it is having 3 custom dependencies developed by our team. 在内部,它具有3个由我们团队开发的自定义依赖项。
All 3 dependencies are boot project and have their @Configuration
. 所有3个依赖项都是引导项目,并且具有@Configuration
。
I am using this dependency 4 in multiple web applications which are having WebMVC implementation. 我在具有WebMVC实现的多个Web应用程序中使用此依赖项4。
Everything is working fine in my local machine. 在我的本地计算机上一切正常。 But when I am pushing this web application on cloud, sometimes libraries getting executed before the web application which is crashing my app intermittently. 但是,当我在云上推送此Web应用程序时,有时库会在Web应用程序之前执行,这会间歇性地使我的应用程序崩溃。 Good thing app is getting recover in few seconds. 好东西应用程序会在几秒钟内恢复。
I did below changes in my libraries (jars/dependencies) and tried on cloud. 我在库(jars / dependencies)中进行了以下更改,并在云上进行了尝试。 After doing these changes ratio of app crash reduces, but unfortunately it is still crashing sometimes and I am able to see dependencies gets executed before application. 完成这些更改后,应用程序崩溃的比率降低了,但是不幸的是,有时它仍然崩溃,并且我能够看到依赖项在应用程序之前就已执行。
@SpringBootApplication
from libraries(dependencies/jars). 从库(依赖项/罐子)中@SpringBootApplication
了@SpringBootApplication
。 It's just in my web application now. 现在就在我的Web应用程序中。 I do not know these are the only steps to make a boot dependency non-executable or I would have to do something else. 我不知道这些是使启动依赖项不可执行的唯一步骤,否则我将不得不做其他事情。 Please let me know if I am missing something. 如果我缺少什么,请告诉我。
Here is the sample off application class of one of my dependency. 这是我的依赖项之一的示例应用程序类。
import org.springframework.context.annotation.ComponentScan;
@ComponentScan
public class LoggingApplication {
}
Sample of Web application main class.
@SpringBootApplication
@EnableWebMvc
@Import(LoggingApplication.class)
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
You didn't expose stacktrace nor provided any specifics of "crash". 您没有公开stacktrace,也没有提供“崩溃”的任何详细信息。 So looking into my crystal ball, this sounds like you are doing some work during wiring phase of Spring IoC container. 因此,看着我的水晶球,听起来您在Spring IoC容器的接线阶段正在做一些工作。 This "work" should be moved into @PostConstruct
handlers, so that you are sure it will be executed after Spring Context is fully created and initialized. 该“工作”应移至@PostConstruct
处理程序中,以确保在完全创建和初始化Spring Context之后执行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.