Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/android-studio/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 无法将spring启动应用程序用作另一个spring启动应用程序的依赖项_Spring Boot - Fatal编程技术网

Spring boot 无法将spring启动应用程序用作另一个spring启动应用程序的依赖项

Spring boot 无法将spring启动应用程序用作另一个spring启动应用程序的依赖项,spring-boot,Spring Boot,无法将spring启动应用程序用作另一个spring启动应用程序的依赖项。有人能告诉我正确的来源吗?我想使用AspectJ(也是spring boot应用程序)实现一个中央日志应用程序,它将侦听不同的spring boot应用程序(可能还有6个其他应用程序)的方法执行,并将数据持久化到DB中 我在pom.xml中使用了下面的配置 org.springframework.boot springbootmaven插件 重新包装 重新包装 执行官 并将其作为对其他spring boot应用程序PO

无法将spring启动应用程序用作另一个spring启动应用程序的依赖项。有人能告诉我正确的来源吗?我想使用AspectJ(也是spring boot应用程序)实现一个中央日志应用程序,它将侦听不同的spring boot应用程序(可能还有6个其他应用程序)的方法执行,并将数据持久化到DB中

我在pom.xml中使用了下面的配置


org.springframework.boot
springbootmaven插件
重新包装
重新包装
执行官
并将其作为对其他spring boot应用程序POM.XML文件的依赖项添加,但仍然没有可用的“com.client.client.NewClass”类型的合格bean*

import org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.boot.CommandLineRunner;
导入org.springframework.boot.SpringApplication;
导入org.springframework.boot.autoconfigure.springboot应用程序;
导入com.client.client.NewClass;
@SpringBoot应用程序
公共类DemoApplication实现CommandLineRunner{
@自动连线
私有新类新类;
公共静态void main(字符串[]args){
run(DemoApplication.class,args);
}
@凌驾
公共无效运行(字符串…参数)引发异常{
System.out.println(newClass.getValue());`在这里输入代码`
}
}

在我看来,您有两种选择:

A)在公共模块中编写AspectJ代码(不是完整的spring启动应用程序)。如果愿意,您可以将其设置为可选依赖项(如果您还不知道的话,可以在maven中研究可选依赖项)

然后在其他应用程序中将该通用模块用作库。如果您想将日志写入数据库,请将日志数据库配置为辅助数据库(再次在spring中通过google了解如何创建两个数据源)

如果要使用此选项,只需更新属性文件和pom.xml


B)编写一个带有REST端点的完整spring引导应用程序,以接收包含要记录的信息的消息。更新每个应用程序以调用REST api并记录信息。

赞成第一种方法。。所以您建议,公共模块应该有将日志写入文件并将其写入数据库的代码。现在,客户端可以使用任何一个或两个功能。我说的对吗?对。AspectJ代码可能需要是通用的,才能拦截6个应用程序的所有用例。例如包名等