Tag: kotlin

我的EL表达式没有在MyFaces 2.3和Spring Boot 2.0.3应用程序下进行评估

我有一个在Spring Boot 2.0.3下运行的MyFaces应用程序,所有Servlets和Context Listeners都已正确注册和配置,并且显然正常工作。 甚至我的index.jsf页面也在渲染。 标记在.xhtml文件上正确处理。 问题是index.jsf页面的所有EL expressions都没有被处理/评估。 不会抛出任何错误,但放置#{myBean.property}的地方始终呈现为空String 。 调试它我看到我的Managed bean的服务器代码没有被调用。 我尝试为许多版本更改el-api和el-impl库,但没有人工作。 我使用的最终版本是el-api 2.2规范,遵循页面https://myfaces.apache.org/core23/myfaces-impl/dependencies.html 由于没有抛出错误,我无法弄清楚问题出在哪里。 有人有这个错误吗? 是否可以在作为jar文件打包的Spring Boot应用程序下运行MyFaces 2.3? 以下是我在Gradle构建文件中使用的依赖项: dependencies { compile “org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version” compile(“org.jetbrains.kotlin:kotlin-reflect”) testCompile group: ‘junit’, name: ‘junit’, version: ‘4.12’ testCompile(‘org.springframework.boot:spring-boot-starter-test’) compile ‘io.github.microutils:kotlin-logging:1.5.4’ compile group: ‘org.apache.myfaces.core’, name: ‘myfaces-impl’, version: ‘2.3.1’ compile group: ‘org.apache.myfaces.core’, name: ‘myfaces-api’, version: ‘2.3.1’ compile group: ‘javax.enterprise’, name: ‘cdi-api’, […]

Kotlin数据类包装

Kotlin介绍了数据类的精彩概念。 这些类将基于构造函数中声明的属性派生equals()/hashCode() , toString() , getters()/setters()和copy()函数: data class KotlinUser(val name: String, val age: Int) 在Java中,这看起来像: public class JavaUser { public JavaUser(String name, Int age) { … } //getters //setters //equals()/hashCode() //toString() } 我的问题是关于在Kotlin中打包这些数据类文件。 来自Java我将JavaUser存储在自己的Class文件中: org.package.foo.JavaUser 由于数据类的简单性,我们是否在Kotlin中以相同的方式存储数据类文件? (即org.package.foo.KotlinUser和每个数据类的单独文件)。 另外,是否不赞成将多个数据类存储在一个类文件中?: org.package.foo.DataClasses包含: data class Foo(val a: String, val b: String) data class Bar(val a: Int, val b: Int) […]

Kotlin 1.2.21 + SimpleXml 2.3.0 – 消耗List错误(必须标记set get方法)

我正在尝试通过Retrofit 2使用SimpleXML来使用XML。经过几个小时与Kotlin的斗争,我决定尝试Java版本然后转换到Kotlin。 Java版本运行良好…… 错误: java.lang.RuntimeException: org.simpleframework.xml.core.MethodException: Annotation @org.simpleframework.xml.ElementList(data=false, empty=true, entry=, inline=true, name=entry, required=true, type=void) must mark a set or get method 我需要一个能够使用该XML的Kotlin模型类。 这是输入: someid somedate someid2 somedate2 Java模型类版本(工作正常): @Root(name = “feed”, strict = false) public class MFeed { @ElementList(name = “entry”, inline = true) private List entriesList; public MFeed(List entriesList) { this.entriesList = entriesList; } […]

如何在Java / Kotlin中创建一个返回复杂类型的Spark UDF?

我正在尝试编写一个返回复杂类型的UDF: private val toPrice = UDF1<String, Map> { s -> val elements = s.split(” “) mapOf(“value” to elements[0], “currency” to elements[1]) } val type = DataTypes.createStructType(listOf( DataTypes.createStructField(“value”, DataTypes.StringType, false), DataTypes.createStructField(“currency”, DataTypes.StringType, false))) df.sqlContext().udf().register(“toPrice”, toPrice, type) 但是每次我用这个: df = df.withColumn(“price”, callUDF(“toPrice”, col(“price”))) 我得到一个神秘的错误: Caused by: org.apache.spark.SparkException: Failed to execute user defined function($anonfun$28: (string) => struct) at […]