我正在尝试执行此查询 -
DROP DATABASE IF EXISTS `hotel`;
GRANT USAGE ON *.* TO 'user'@'localhost';
DROP USER 'user'@'localhost';
CREATE USER user@localhost IDENTIFIED BY 'user';
CREATE DATABASE `hotel`
CHARACTER SET 'utf8'
COLLATE 'utf8_general_ci';
GRANT USAGE ON *.* to 'user'@'localhost' identified by 'user';
Run Code Online (Sandbox Code Playgroud)
但我总是得到错误
GRANT USAGE ON *.* TO 'user'@'localhost' Error Code: 1133. Can't find any matching row in the user table 0.000 sec
Run Code Online (Sandbox Code Playgroud)
Grant usage如果用户不存在,我认为创建新用户.怎么了?
我有一个关于Git基础知识的问题.
基本上,在Git中被称为"添加到索引"的行为是什么意思?我这样理解:
如果任何文件git计算SHA-1总和,那么基本上添加到索引意味着它计算SHA-1总和并将文件添加到暂存区域.
我对么?
我的意思是例如我可以创建表格
create table XTable
(
idt int not null primary key,
value nvarchar(50),
idq int,
constraint fk_idq foreign key(idq) references YTable(idq)
)
Run Code Online (Sandbox Code Playgroud)
我可以像这样创造它
create table XTable
(
idt int not null primary key,
value nvarchar(50),
idq int,
foreign key(idq) references YTable(idq)
)
Run Code Online (Sandbox Code Playgroud)
我通常在第二个例子中创建表格,但现在我对第一个例子感到好奇.有什么不同?
我有简单的脚本
package com.lapots.game.journey.ims.example
fun main(args: Array<String>) {
println("Hello, world!")
}
Run Code Online (Sandbox Code Playgroud)
这是gradle任务
task runExample(type: JavaExec) {
main ='com.lapots.game.journey.ims.example.Example'
classpath = sourceSets.main.runtimeClasspath
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行任务时,gradle runExample我得到了错误
Error: Could not find or load main class com.lapots.game.journey.ims.example.Example
运行应用程序的正确方法是什么?
我正在使用Spring boot和jpa.它就在这里
我有一个看起来像这样的域名.此外,它似乎Entity已被弃用,因此我正在使用DynamicUpdate.
@Data
@AllArgsConstructor
@NoArgsConstructor
@DynamicUpdate
public class Person {
private String id;
private String name;
}
Run Code Online (Sandbox Code Playgroud)
我的SpringBootApplication班级看起来像这样
@SpringBootApplication
@ComponentScan("com.lapots.breed.platform.cloud.boot")
@EnableJpaRepositories("com.lapots.breed.platform.cloud.boot.repository")
@EntityScan("com.lapots.breed.platform.cloud.boot.domain")
public class JavaCloudSampleApplication {
public static void main(String[] args) {
SpringApplication.run(JavaCloudSampleApplication.class, args);
}
// executed after all beans instantiated
@Bean
public CommandLineRunner data(PersonRepository repository) {
return (args) -> {
repository.save(new Person(UUID.randomUUID().toString(), "Nike"));
};
}
}
Run Code Online (Sandbox Code Playgroud)
repository 类看起来像这样
@Repository
public interface PersonRepository extends JpaRepository<Person, String> {
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试执行一些.sql脚本,然后使用部署Web应用程序gradle tomcat plugin.
但是,当我尝试运行时,gradle我遇到了错误

我buildscript看起来像这样
buildscript {
//repository location
repositories {
mavenCentral()
jcenter()
}
//dependencies
//did not divide them into runtime&compile
dependencies {
//aspectJ dependencies
compile 'org.aspectj:aspectjlib:1.6.2'
compile 'org.aspectj:aspectjrt:1.7.4'
compile 'org.aspectj:aspectjweaver:1.7.4'
//servlet
compile 'javax.servlet:javax.servlet-api:3.0.1'
//jdbc postresql
compile 'org.postgresql:postgresql:9.2-1004-jdbc4'
//commons dbcp
compile 'commons-dbcp:commons-dbcp:1.2.2'
//spring & spring MVC dependencies
compile 'org.springframework:spring-core:' + spring_version
compile 'org.springframework:spring-web:' + spring_version
compile 'org.springframework:spring-webmvc:' + spring_version
compile 'org.springframework:spring-jdbc:' + spring_version
compile 'org.springframework:spring-aspects:' + spring_version
//spring security
compile 'org.springframework.security:spring-security-core:' + …Run Code Online (Sandbox Code Playgroud) 我想将字符串列表转换为大写.
这是我的代码:
List<String> list = Arrays.asList("abc", "def", "ghi");
List<String> upped = list.stream().map(String::toUpperCase).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
有没有更简单/更好的方法来做到这一点?
在java.util.TreeMap javadoc中有这样的声明:
此类中的方法返回的所有Map.Entry对及其视图表示生成时映射的快照.它们不支持Entry.setValue方法.(但请注意,可以使用put更改关联映射中的映射.)
我不明白这一行.他们以什么方式不支持setValue方法?当我使用entrySet()并迭代Map.Entry对象时,它设置值很好.
Map<String, Integer> map = new TreeMap<>();
map.put("dbc", 1);
map.put("abc", 1);
map.put("cbc", 1);
for(Map.Entry<String, Integer> item: map.entrySet()) {
item.setValue(1);
}
Run Code Online (Sandbox Code Playgroud) 有没有办法定义全局变量build.gradle并使它们可以从任何地方访问.
我的意思是这样的
def variable = new Variable()
def method(Project proj) {
def value = variable.value
}
Run Code Online (Sandbox Code Playgroud)
因为那样它告诉我它cannot find property.我也想对这些方法做同样的事情.我的意思是这样的
def methodA() {}
def methodB() { methodA() }
Run Code Online (Sandbox Code Playgroud) 我正在使用r2dbc,r2dbc-h2并且是实验性的spring-boot-starter-data-r2dbc
implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc:0.1.0.M1'
implementation 'org.springframework.data:spring-data-r2dbc:1.0.0.RELEASE' // starter-data provides old version
implementation 'io.r2dbc:r2dbc-h2:0.8.0.RELEASE'
implementation 'io.r2dbc:r2dbc-pool:0.8.0.RELEASE'
Run Code Online (Sandbox Code Playgroud)
我创建了反应式存储库
public interface IJsonComparisonRepository extends ReactiveCrudRepository<JsonComparisonResult, String> {}
Run Code Online (Sandbox Code Playgroud)
还添加了一个自定义脚本,在启动时在 H2 中创建一个表
@SpringBootApplication
public class JsonComparisonApplication {
public static void main(String[] args) {
SpringApplication.run(JsonComparisonApplication.class, args);
}
@Bean
public CommandLineRunner startup(DatabaseClient client) {
return (args) -> client
.execute(() -> {
var resource = new ClassPathResource("ddl/script.sql");
try (var is = new InputStreamReader(resource.getInputStream())) {
return FileCopyUtils.copyToString(is);
} catch (IOException e) {
throw new RuntimeException(e);
} …Run Code Online (Sandbox Code Playgroud)