-1

I'm trying to tell the ComponentScan annotation in Spring to import just a single class following this example: using ComponentScan or context:component-scan with only one class

@ComponentScan(
    basePackages = {"com.example.controllers"}, 
    useDefaultFilters = false,
    includeFilters = {
        @ComponentScan.Filter(type = ASSIGNABLE_TYPE, value = ExampleController.class)
    })
class MyControllerTestConfig {  
}

I believe this is ported to Scala as follows:

@Configuration
@ComponentScan(
    basePackages = Array("com.example.controllers"), 
    useDefaultFilters = false,
    includeFilters = Array(
        new ComponentScan.Filter(type = ASSIGNABLE_TYPE,   // fails
            value = Array(classOf[ExampleController]))
    ))
class MyControllerTestConfig {  
}

However, Scala doesn't let me use the word "type" as a parameter as it is a keyword in scala :-(

Is there a way to supply "type" as an annotation parameter in scala?

Community
  • 1
  • 1
user48956
  • 14,850
  • 19
  • 93
  • 154

1 Answers1

2

using backticks you can use type as a keyword.

e.g.

val `type` :String = "abc"
Vikas Pandya
  • 1,998
  • 1
  • 15
  • 32