当前位置: 首页>>代码示例>>Scala>>正文


Scala ApplicationContext类代码示例

本文整理汇总了Scala中org.springframework.context.ApplicationContext的典型用法代码示例。如果您正苦于以下问题:Scala ApplicationContext类的具体用法?Scala ApplicationContext怎么用?Scala ApplicationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ApplicationContext类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: AppConfiguration

//设置package包名称以及导入依赖的类
package com.piotrglazar.receiptlottery.extension

import akka.actor.ActorSystem
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.{Bean, Configuration}

import scala.concurrent.ExecutionContext

@Configuration
class AppConfiguration {

  @Autowired
  var applicationContext: ApplicationContext = _

  @Bean
  def actorSystem(): ActorSystem = {
    val sys = ActorSystem()
    SpringExtension.provider.get(sys).initialize(applicationContext)
    sys
  }

  @Bean
  def executionContext(actorSystem: ActorSystem): ExecutionContext =
    actorSystem.dispatcher
} 
开发者ID:piotrglazar,项目名称:receipt-lottery,代码行数:27,代码来源:AppConfiguration.scala

示例2: SpringRunner

//设置package包名称以及导入依赖的类
package com.ntsdev.run

import com.ntsdev.config.{LocalGraphConfiguration, RemoteGraphConfiguration, EnvironmentConfig}
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.{AnnotationConfigApplicationContext, Configuration}

@Configuration
class SpringRunner

object SpringRunner extends App with EnvironmentConfig {
  val logger = LoggerFactory.getLogger(getClass)

  logger.info(s"Active Spring Profile: [$activeSpringProfile]")

  if("cloud" equals activeSpringProfile) {
    logger.info("Loading cloud configuration...")
    val context: ApplicationContext = new AnnotationConfigApplicationContext(classOf[RemoteGraphConfiguration])
  }
  else {
    import com.ntsdev.service.TestDataService
    logger.info("Loading local configuration...")
    val context: ApplicationContext = new AnnotationConfigApplicationContext(classOf[LocalGraphConfiguration])
    val testDataService: TestDataService = context.getBean("testDataService").asInstanceOf[TestDataService]
    testDataService.loadTestData()
  }
} 
开发者ID:neilshannon,项目名称:atlanta-scala-microservice,代码行数:28,代码来源:SpringRunner.scala


注:本文中的org.springframework.context.ApplicationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。