- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我必须将企业应用程序转换为 spring。到目前为止,我一切正常。但是我仍然需要替换我的两个 bean 上的 @Startup 注释。
是否有 spring 等价物,或者你将如何在 spring 中做到这一点?
提前致谢!
最佳答案
不确定这是否是您要的。我总是在我的 Spring-beans 中使用 @PostConstruct 注释来做一些需要在应用程序启动时完成的事情:
@Component
public class SchedulerBootstrap {
@Autowired
MyRepository myRepository;
@Autowired
OpenPropertyPlaceholderConfigurer configurer;
@PostConstruct
/**
* This method will be called after the bean has been
* instantiated and all dependencies injected.
*/
public void init() {
}
}
添加一个示例,说明如何编写单元测试以试验 bean 在 Spring 上下文中的行为。
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
@ContextConfiguration(locations = {"classpath:spring-context.xml"})
public class BootstrapTest extends AbstractJUnit4SpringContextTests {
@Autowired
SchedulerBootstrap schedulerBootstrap;
@Test
public void myTest() {
//Some code that berifies that init-method had been called.
//Or start unit test in debug-mode and add a breakpoint in the
//init-method, you will see it being called before the test is executed.
}
}
关于java - 有没有等同于@Startup的spring?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21600153/
我试图在 GCE 上启动时让以下脚本在 CentOS 实例上运行。 我在实例名称上设置了自定义元数据“启动脚本”,并将以下脚本作为值。 该脚本不会在启动、重启或运行/usr/share/google/
我在我的一个类中添加了一个 startUp-Method,它立即退出了我的图像。有没有办法阻止 Photo 执行该方法以便我可以修复它? 最佳答案 不,这是一个持续讨论的问题。见 this post在
我在启动类中收到“'Startup.Configuration' 和'Startup.Configuration' 之间的歧义”错误。我不知道我做了什么导致这个问题。我所做的只是创建了一个 DBCon
asp.net 5 中的 Startup 类让我觉得很奇怪。它不是类 Startup : ISomething 或 Startup : BaseSomething ,其中接口(interface)或基
我有这个代码: https://github.com/nbarbettini/SimpleTokenProvider/tree/master/test/SimpleTokenProvider.Test
这个问题在这里已经有了答案: What does the servlet value signify (11 个答案) 关闭 7 年前。 考虑到同样的问题,我是 J2EE 的新手,请回答。当我们使
关闭。这个问题是opinion-based .它目前不接受答案。 想改进这个问题?更新问题,以便 editing this post 提供事实和引用来回答它. 8年前关闭。 Improve this
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
如何以编程方式查找在设备启动时启动的应用程序列表。有什么方法可以以编程方式禁用您不需要的自动启动应用程序。 谢谢 最佳答案 除了删除有问题的应用程序之外,别无他法。 API 表示系统必须接受对 BOO
我知道它们用于调用 main(),但如果那是唯一目的,那么拥有不同的 crt 文件有什么意义。为什么不使用默认的而不是创建自己的? 最佳答案 CRT 文件是 C 运行时文件。您最有可能遇到的是 crt
我正在运行一个带有在重启时调用的启动脚本的 EC2 实例。此启动脚本在启动容器之前检查 docker 守护进程是否正在运行,但失败并显示错误:Post http:///var/run/docker.s
我有一个项目,其中包含许多具有自己的日志记录的“工具”类。这些日志文件是在应用程序启动时创建的,但在使用之前一直为空。 是否可以告诉logback在启动时不应该创建空文件?但是仅在使用它们时? 不知何
我正在尝试创建自己的自定义钻取功能,其中 URL dynamics://0?myfunction_123456 将启动我自己的代码。 在 C\SysStartupCmd\construct 中,这个基
我有一个 RFID 模块连接到我的 beaglebone 并使用 python 代码读取 ID 标签。现在,我希望我的 python 代码在没有任何命令的情况下登录我的 beaglebone 时直接在
我试图探索一些 ASP.NET-5 应用程序,我在其中找到了 startup.cs 文件。我们在这里设置路由和所有(当然不仅仅针对路由)。我还看到一些演示,其中显示了依赖注入(inject)的使用 h
我遇到以下问题。我有一个带有 UI、nib 等的 Cocoa 应用程序。我需要能够在后台或前台启动该应用程序。换句话说,我需要前者中的 NSApplicationActivationPolicyPro
我在 Windows 上,根据 this startup.el 用于emacs 的启动。但是当我在这个文件中设置代码时(C:\Users\frountch\Progs\emacs24\share\em
asp.net mvc 6 beta5 我尝试使用 config.json 来激活\禁用日志记录 public IConfiguration Configuration { get; set; } p
我一直在查看 ASP.NET Web API 默认项目,它带有 ASP.NET Identity 身份验证,它使用 Owin。我在谷歌上搜索了一下,发现 Owin 旨在将应用程序与服务器分离,并且它的
我是一名优秀的程序员,十分优秀!