dh44t
02/05/2016, 1:03 PMjasoet-gdp
02/06/2016, 1:57 AMorangy
getBean
problem, please try it on some real projectjasoet-gdp
02/10/2016, 8:03 AMjasper
02/12/2016, 6:41 AMinit
does not satisfy but constructor()
does.jasper
02/12/2016, 6:49 AMorangy
dh44t
02/15/2016, 1:44 PMdh44t
02/15/2016, 1:45 PMelezium
02/15/2016, 1:47 PMherder
02/16/2016, 1:24 PM@SpringBootApplication
@EnableSolrRepositories
@Configuration
open class ReindexingServiceApplication {
@Bean
@Autowired
open fun init(repository: ArticleRepository) : ArticleDoc {
val findByType = repository.findByType("article", PageRequest(0, 1))
return findByType.iterator().next();
}
fun main(args: Array<String>) {
SpringApplication.run(ReindexingServiceApplication::class, *args)
}
}
, but IntelliJ complains like this when I want to run it: Error: Main method is not static in class se.aftonbladet.api.ReindexingServiceApplication, please define the main method as:
public static void main(String[] args)
The project started as a Java Boot project, but I converted it to Kotlin. Is that maybe why Intellij is confused?orangy
main
out of the class to make it top level, or put it inside companion object
inside a classherder
02/16/2016, 1:31 PMherder
02/16/2016, 3:36 PMBeanDefinitionReader
throws an Exception when I specify a class in the run() method, but not when I provide the class name.
java.lang.IllegalArgumentException: Invalid source type class kotlin.reflect.jvm.internal.KClassImpl
at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:144) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
This seems to have worked in previous versions, since I see Boot projects on Github which use the class?herder
02/16/2016, 3:36 PM@SpringBootApplication
open class ReindexingServiceApplication
public fun main(args: Array<String>) {
SpringApplication.run(ReindexingServiceApplication::class, *args)
}
herder
02/16/2016, 3:52 PMherder
02/16/2016, 4:14 PMstarbuxman
02/17/2016, 1:36 PMdh44t
02/17/2016, 1:37 PMstarbuxman
02/17/2016, 1:37 PMstarbuxman
02/17/2016, 1:37 PM@Bean
open fun etlFlow(messageSource: MessageSource<File>,
@Qualifier (BatchApplication.JOB_NAME) etlJob: Job): IntegrationFlow {
open class X : GenericHandler <File> {
override fun handle(file: File, p1: MutableMap<String, Any>?): Any? {
println("absolute path: ${file.absolutePath}")
return null
}
}
val gh: GenericHandler<File> = GenericHandler { file, headers ->
println (file.absoluteFile)
null
}
return IntegrationFlows
.from(messageSource, Consumer<SourcePollingChannelAdapterSpec> {
it.poller({ pf -> pf.fixedRate(1000 * 10) })
})
.handle(File::class.java, X())
.get()
}
starbuxman
02/17/2016, 1:37 PMhandle
method takes a GenericHandler<T>
starbuxman
02/17/2016, 1:37 PMstarbuxman
02/17/2016, 1:38 PMgh
), its public final and it failsdh44t
02/17/2016, 1:38 PMstarbuxman
02/17/2016, 1:38 PMstarbuxman
02/17/2016, 1:38 PMgh
non final ?starbuxman
02/17/2016, 1:39 PMopen val gh : ..
didnt work, for exampledh44t
02/17/2016, 1:40 PMdh44t
02/17/2016, 1:40 PM