我尝试通过heroku run bash
运行kotlin spring webapp。然后我跑了:
java -cp ./build/libs/pss_kotlin-1.0-SNAPSHOT.jar pl.makzyt.pss_kotlin.MainKt
然后我收到此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at pl.makzyt.pss_kotlin.MainKt.main(Main.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
我知道如果我得到kotlin-runtime.jar,我就可以运行它。是否有可能通过某些命令获取它,还是应该手动下载?
修改
以下是我的build.gradle依赖项:
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile group: 'org.springframework.boot',
name: 'spring-boot-autoconfigure',
version: '2.0.0.RELEASE'
compile group: 'org.springframework.boot',
name: 'spring-boot-starter-data-jpa',
version: '2.0.0.RELEASE'
compile group: 'org.springframework.boot',
name: 'spring-boot-starter-web',
version: '2.0.0.RELEASE'
compile group: 'org.postgresql',
name: 'postgresql',
version: '42.2.2'
compile group: 'org.hibernate',
name: 'hibernate-core',
version: '5.2.12.Final'
compile group: 'org.hibernate',
name: 'hibernate-entitymanager',
version: '5.2.12.Final'
compile group: 'javax.xml.bind',
name: 'jaxb-api',
version: '2.1'
compile group: 'org.springframework.boot',
name: 'spring-boot-starter-thymeleaf',
version: '2.0.0.RELEASE'
compile group: 'nz.net.ultraq.thymeleaf',
name: 'thymeleaf-layout-dialect',
version: '2.3.0'
}
答案 0 :(得分:2)
如果正确配置了spring boot应用程序(在build.gradle中应用了spring boot插件),则只需运行jar即可。
<div class="plat">
<p>apple</p>
<p>pie</p>
<p>cheese</p>
</div>
<div class="duck">
<p>apple</p>
<p>pie</p>
<p>cheese</p>
</div>
<div class="bill">
<p>apple</p>
<p>pie</p>
<p>cheese</p>
</div>
<div class="dan">
<p>apple</p>
<p>pie</p>
<p>cheese</p>
</div>
<div class="five">
<p>apple</p>
<p>pie</p>
<p>cheese</p>
</div>
<div class="six">
<p>apple</p>
<p>pie</p>
<p>cheese</p>
</div>
<div class="seven">
<p>apple</p>
<p>pie</p>
<p>cheese</p>
</div>
<div class="eight">
<p>apple</p>
<p>pie</p>
<p>cheese</p>
</div>
您不需要使用def generator(l):
for i in l:
yield i
if __name__ == '__main__':
very_large_list = [1,2,3]
for i in generator(very_large_list): # Iterate over the list dynamically without storing in memory
print i
选项,因为Spring Boot会重新打包jar中的所有依赖项,这就是您找不到类错误的原因。
答案 1 :(得分:0)
我不确定你为什么会收到这个错误。但您可能想尝试从https://start.spring.io生成一个新的Spring + Kotlin应用程序,并将Maven依赖项/插件复制到:
中。