我尝试使用Kotlin创建第一个Spring Boot应用程序。所以,也许我犯了一些明显的错误或类似的东西。
我的 gradle.build 是:
buildscript {
ext.kotlin_version = '1.0.5-2'
ext.spring_boot_version = '1.4.2.RELEASE'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_version"
}
}
apply plugin: 'idea'
apply plugin: 'kotlin'
apply plugin: 'application'
jar {
baseName = 'rest-voter'
version = '0.1.0'
}
springBoot {
mainClass = 'ru.hixon.Application'
}
repositories {
jcenter()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE"
testCompile 'junit:junit'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
错误是:
C:\Users\Desktop\rest-voter>gradlew build
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Desktop\rest-voter\build.gradle' line: 22
* What went wrong:
A problem occurred evaluating root project 'rest-voter'.
> Could not find method springBoot() for arguments [build_3594if1jtm90vgb7v8evp206i$_run_closure2@459003a0] on root project 'rest-voter'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 12.351 secs
我的主要课程是:
package ru.hixon
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
@SpringBootApplication
open class Application {
}
fun main(args: Array<String>) {
SpringApplication.run(Application::class.java, *args)
}
here是我的应用程序的完整代码。
答案 0 :(得分:4)
你需要:
import java.io.*;
import java.util.Scanner;
public class caltax
{
public static void main (String[] args)
{
String lname[] = new String [12];
String fname[] = new String [12];
Double income[] = new Double [12];
double sincome=0.0;
int i, count=1;
try
{
Scanner infile = new Scanner (new FileInputStream("family.dat"));
while (infile.hasNextLine())
{
lname[12] = infile.next();
fname[12] = infile.next();
income[12] = infile.nextDouble();
}//while
infile.close();
}//try
catch (Exception e)
{
System.out.println("Check the file");
}//catch block
for(i=0;i<12;i++)
{
if (lname[i].equals(lname[i+1]))
{
count++;
sincome += income[i];
//object t is created and constrctor is called
taxcalculation t = new taxcalculation (count, lname, fname, sincome);
t.taxowned();
}//if
}//for
}//main
}//class
以及:)
导入依赖关系是不够的。