我最近已经完成了许多React教程,特别是那些采用Flux架构的教程.所有这些教程都react/lib/keymirror以各种形式使用.
我明白了什么是这样,但我不相信我完全理解它提供的好处.然而,这可能表明我的理解是什么它是不完全正确!
我的理解是:
我想问题是,在中小规模的应用程序中,在keyMirror中定义一次常量,然后在两个不同的位置(操作和存储)中要求和引用它们提供与Strings相比的任何实际好处,仅在操作和存储中引用?
如果像Bill所说的那样,在一个地方查看常量列表会有所帮助,那么只保留一个带有字符串常量的txt文件的代码就更少了.
我创建了一个简单的java"echo"应用程序,它接受用户的输入并将其显示给他们以演示该问题.我可以使用IntelliJ的内部"运行"命令,以及执行由...生成的编译的java文件时运行此应用程序gradle build.但是,如果我尝试使用执行应用程序gradle run,我会从扫描程序中抛出NoSuchElementException.
我认为gradle或应用程序插件特别对系统IO做了一些奇怪的事情.
应用
package org.gradle.example.simple;
import java.util.Scanner;
public class HelloWorld {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
String response = input.nextLine();
System.out.println(response);
}
}
Run Code Online (Sandbox Code Playgroud)
的build.gradle
apply plugin: 'java'
version '1.0-SNAPSHOT'
apply plugin: 'java'
jar {
manifest {
attributes 'Main-Class': 'org.gradle.example.simple.HelloWorld'
}
}
apply plugin: 'application'
mainClassName = "org.gradle.example.simple.HelloWorld"
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
Run Code Online (Sandbox Code Playgroud)
有关如何使用此应用程序的任何想法gradle run?