本文整理了Java中org.springframework.context.annotation.AnnotationConfigApplicationContext.start()
方法的一些代码示例,展示了AnnotationConfigApplicationContext.start()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotationConfigApplicationContext.start()
方法的具体详情如下:
包路径:org.springframework.context.annotation.AnnotationConfigApplicationContext
类名称:AnnotationConfigApplicationContext
方法名:start
暂无
代码示例来源:origin: apache/incubator-dubbo
/**
* In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before
* launch the application
*/
public static void main(String[] args) throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
context.start();
System.in.read();
}
代码示例来源:origin: apache/incubator-dubbo
/**
* In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before
* launch the application
*/
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
context.start();
DemoService service = context.getBean("demoServiceComponent", DemoServiceComponent.class);
String hello = service.sayHello("world");
System.out.println("result :" + hello);
}
代码示例来源:origin: Lovelcp/blog-demos
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(RabbitMQConfig.class);
context.start();
}
}
代码示例来源:origin: apache/incubator-dubbo-samples
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
context.start();
GreetingServiceConsumer greetingServiceConsumer = context.getBean(GreetingServiceConsumer.class);
String hello = greetingServiceConsumer.doSayHello("annotation");
System.out.println("result: " + hello);
}
代码示例来源:origin: xuminwlt/j360-dubbo-app-all
public static void main(String[] args) throws InterruptedException {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfiguration.class);
context.start();
log.info("service started successfully!");
Runtime.getRuntime().addShutdownHook(new Thread(){
@Override
public void run() {
log.info("Shutdown hook was invoked. Shutting down Service.");
context.close();
}
});
CountDownLatch countDownLatch = new CountDownLatch(1);
countDownLatch.await();
}
}
代码示例来源:origin: apache/incubator-dubbo-samples
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
context.start();
GreetingServiceConsumer greetingServiceConsumer = context.getBean(GreetingServiceConsumer.class);
String hello = greetingServiceConsumer.doSayHello("configuration");
System.out.println("result: " + hello);
}
代码示例来源:origin: apache/incubator-dubbo-samples
public static void main(String[] args) throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
context.start();
final AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction");
String hello = annotationAction.doSayHello("world");
System.err.println("result :" + hello);
System.in.read();
}
代码示例来源:origin: remoting/dubbox
public void start() {
String configPath = ConfigUtils.getProperty(SPRING_JAVACONFIG);
if (configPath == null || configPath.length() == 0) {
configPath = DEFAULT_SPRING_JAVACONFIG;
}
context = new AnnotationConfigApplicationContext(configPath);
context.start();
}
代码示例来源:origin: remoting/dubbox
public void start() {
String configPath = ConfigUtils.getProperty(SPRING_JAVACONFIG);
if (configPath == null || configPath.length() == 0) {
configPath = DEFAULT_SPRING_JAVACONFIG;
}
context = new AnnotationConfigApplicationContext(configPath);
context.start();
}
代码示例来源:origin: xuminwlt/j360-dubbo-app-all
public static void main(String[] args) throws InterruptedException {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfiguration.class);
context.start();
UserRepository userRepository = (UserRepository) context.getBean("userRepository");
CacheConfiguration cacheConfiguration = (CacheConfiguration) context.getBean("cacheConfiguration");
while (true) {
String name = userRepository.getUserCacheable(1L);
System.out.println(String.format("name=%s", name));
System.out.println(String.format("timeout=%s", cacheConfiguration.getTimeout()));
TimeUnit.SECONDS.sleep(5);
}
}
}
代码示例来源:origin: mp911de/spring-cloud-vault-config-samples
public static void main(String[] args) {
System.setProperty("spring.cloud.appId", "my-cloud-app");
System.setProperty("spring.cloud.my-vault-service",
"https://localhost:8200?token=my-token");
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
MyConfig.class, ClientComponent.class);
context.start();
ClientComponent component = context.getBean(ClientComponent.class);
log.info("VaultOperations (hash): {}", component.getVaultOperations());
context.stop();
}
代码示例来源:origin: apache/incubator-dubbo-samples
public static void main(String[] args) throws Exception {
new EmbeddedZooKeeper(2181, false).start();
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
context.start();
System.in.read();
}
代码示例来源:origin: apache/incubator-dubbo-samples
public static void main(String[] args) throws Exception {
new EmbeddedZooKeeper(2181, false).start();
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
context.start();
System.in.read();
}
代码示例来源:origin: apache/incubator-dubbo-samples
public static void main(String[] args) throws Exception {
new EmbeddedZooKeeper(2181, false).start();
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
context.start();
System.in.read();
}
代码示例来源:origin: stackoverflow.com
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
// all other initialisation part ...
// before! refresh
ctx.setId("portal-lasg-appCtx-id");
// now refresh ..
ctx.refresh();
ctx.start();
代码示例来源:origin: mp911de/spring-cloud-vault-config-samples
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
VaultConnectorsConfig.class, VaultConfig.class);
context.start();
Cloud cloud = context.getBean(Cloud.class);
SslConfiguration sslConfiguration = context.getBean(SslConfiguration.class);
VaultServiceInfo vaultServiceInfo = (VaultServiceInfo) cloud
.getServiceInfos(VaultOperations.class).get(0);
VaultServiceConnectorConfig config = VaultServiceConnectorConfig.builder()
.sslConfiguration(sslConfiguration).build();
VaultOperations vaultOperations = cloud
.getSingletonServiceConnector(VaultOperations.class, config);
VaultResponse response = vaultOperations
.read(vaultServiceInfo.getBackends().get("generic") + "/application");
log.info("Retrieved app-key: {}", response.getData().get("app-key"));
context.stop();
}
代码示例来源:origin: amoAHCP/spring-vertx-ext
private static void addPostprocessorAndUpdateContext(Class<?> currentVerticleClass,
AnnotationConfigApplicationContext annotationConfigApplicationContext) {
annotationConfigApplicationContext.addBeanFactoryPostProcessor(new SpringSingleVerticleConfiguration(currentVerticleClass));
annotationConfigApplicationContext.refresh();
annotationConfigApplicationContext.start();
annotationConfigApplicationContext.registerShutdownHook();
}
代码示例来源:origin: mp911de/spring-cloud-vault-config-samples
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
VaultConfiguration.class);
context.start();
VaultTemplate vaultTemplate = context.getBean(VaultTemplate.class);
MySecretData mySecretData = new MySecretData();
mySecretData.setUsername("walter");
mySecretData.setPassword("white");
vaultTemplate.write(
"secret/myapplication/user/3128", mySecretData);
log.info("Wrote data to Vault");
VaultResponseSupport<MySecretData> response = vaultTemplate.read(
"secret/myapplication/user/3128", MySecretData.class);
log.info("Retrieved data {} from Vault", response.getData().getUsername());
context.stop();
}
代码示例来源:origin: mp911de/spring-cloud-vault-config-samples
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
VaultConfiguration.class);
context.start();
PersonRepository repository = context.getBean(PersonRepository.class);
Person person = new Person();
person.setId("heisenberg");
person.setFirstname("Walter");
person.setLastname("White");
person.setSsn("1234");
repository.save(person);
log.info("Wrote data to Vault");
VaultTemplate template = context.getBean(VaultTemplate.class);
VaultResponse response = template.read("secret/person/heisenberg");
log.info("Retrieved data {} from Vault via Template API", response.getData());
Optional<Person> loaded = repository.findById(person.getId());
log.info("Retrieved data {} from Vault via Repository", loaded.get());
context.stop();
}
代码示例来源:origin: infiniteautomation/ma-core-public
protected CompletableFuture<ApplicationContext> springRuntimeContextInitialize() {
@SuppressWarnings("resource")
AnnotationConfigApplicationContext runtimeContext = new AnnotationConfigApplicationContext();
runtimeContext.setId(MangoWebApplicationInitializer.RUNTIME_CONTEXT_ID);
runtimeContext.getEnvironment().getPropertySources().addLast(new MangoPropertySource("envProps", Common.envProps));
runtimeContext.register(MangoRuntimeContextConfiguration.class);
runtimeContext.refresh();
runtimeContext.start();
return MangoRuntimeContextConfiguration.getFutureRuntimeContext();
}
内容来源于网络,如有侵权,请联系作者删除!