比方说,我有一个带注释的Kotlin类:
@Entity @Table(name="user") data class User (val id:Long, val name:String)
Run Code Online (Sandbox Code Playgroud)
如何从@Table注释中获取name属性的值?
fun <T> tableName(c: KClass<T>):String {
// i can get the @Table annotation like this:
val t = c.annotations.find { it.annotationClass == Table::class }
// but how can i get the value of "name" attribute from t?
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用maven-source-plugin为我的kotlin项目创建一个source.jar,但似乎maven-source-plugin对kotlin项目效果不佳.
当我运行"mvn source:jar"时,输出消息总是说:
[INFO] No sources in project. Archive not created.
Run Code Online (Sandbox Code Playgroud)
这是我项目的pom文件中的maven-source-plugin配置:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<attach>true</attach>
<includes>
<!-- i am trying to specify the include dir manually, but not work -->
<include>${project.basedir}/src/main/kotlin/*</include>
</includes>
<forceCreation>true</forceCreation>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何使用maven-source-plugin附加kotlin源文件?
谢谢~~
IntelliJ无法在Maven模块中找到类,即使我将jar依赖项添加到pom.xml中也是如此.
我创建了一个Maven模块:test-intellij.然后我创建了一个类TestApp,并使其实现ApplicationContextAware如下:
public class TestApp implements ApplicationContextAware{
}
Run Code Online (Sandbox Code Playgroud)
IntelliJ告诉我:"找不到类ApplicationContextAware".所以我按下了"alt + enter",然后从弹出的提示我选择了"添加maven依赖".
执行此操作后,下面的依赖项已成功添加到pom.xml中:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但是当我尝试导入ApplicationContextAware类时,IntelliJ仍然无法找到要导入的ApplicationContextAware类.
有人可以帮我解决这个问题吗?
我在grails 2.3.4中使用slf4j"DailyRollingFileAppender".
当我尝试使用变量作为"文件"参数的一部分时,grails总是在应用程序启动时打印一些错误日志.
但我的应用程序的日志消息可以按预期打印到指定的"user-event.log",尽管grails会给我这些错误消息.
下面是我的log4j配置:
log4j = {
// Example of changing the log pattern for the default console appender:
appenders {
console name: 'stdout', layout: pattern(conversionPattern: '%c{2} %m%n')
appender new DailyRollingFileAppender(
name: "userEventLog",
file: "${event.log.dir}/user-event.log",
layout: pattern(conversionPattern: '%m%n'),
datePattern: "'.'yyyy_MM_dd",
threshold: org.apache.log4j.Level.INFO
)
}
info userEventLog: "app.bean.log.UserEventLog"
}
Run Code Online (Sandbox Code Playgroud)
"event.log.dir"变量定义如下:
environments {
development {
// event log dir
event.log.dir = "${userHome}/workspace/app/logs/event"
}
production {
// event log dir
event.log.dir = "/opt/www/app/logs/event"
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序启动时在grails控制台中打印的错误消息是:
| Error log4j:ERROR Property missing when …Run Code Online (Sandbox Code Playgroud) 我是JavaFX和tornadofx的新手,现在我需要创建一些高度自定义的UI组件(包括提交按钮,文本输入字段,密码输入字段,日期时间选择器,下拉选择器等),如下图所示:
那么,创建这些组件的最佳做法是什么?我的问题包括:
谢谢(这个问题也贴在这里:https://github.com/edvin/tornadofx/issues/498)