Spring Boot 使设置一个简单的应用程序变得非常容易。但是我需要更长的时间才能真正获得一个可以上传到远程服务器的 jar 文件。我正在使用 IntelliJ,没有命令行,我使用 gradle。该应用程序以某种方式运行在 Intellij 之外。但是创建的文件在哪里?Bootjar 中的 jar 在哪里?
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
bootJar {
baseName = 'gs-spring-boot'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
testCompile("org.springframework.boot:spring-boot-starter-test")
// add spring data repos
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.postgresql:postgresql:42.2.4")
// REST interface
compile("org.springframework.boot:spring-boot-starter-data-rest")
// Security
compile("org.springframework.boot:spring-boot-starter-security")
}
Run Code Online (Sandbox Code Playgroud)
更新:添加了项目结构的图片:
更新 2:文件夹结构:
我正在实现一个自定义上下文菜单,它基本上是一个名为gripmenu包含几个其他小部件的小部件。如果用户左键单击,则应出现此菜单。要在用户单击外部时隐藏或删除它,我需要以某种方式检查用户是否单击其他地方。我的计划是询问其所有子小部件->hasFocus(),如果没有一个具有焦点,我将关闭菜单。但不幸的是我无法设定焦点。为什么?我的代码是:
gripmenu = new GripMenu(this);
gripmenu->setFocus();
Run Code Online (Sandbox Code Playgroud)
在gripmenu的构造函数中:
GripMenu::GripMenu(){
[... set things up]
ui->lineEdit->setFocus(); // or any other widget to focus,
// even this->setFocus() does not work: see below:
qDebug() << ui->lineEdit->hasFocus(); // returns false!
}
Run Code Online (Sandbox Code Playgroud)
怎么可能刚设置焦点就没有焦点呢?
最后,我的目标是模仿典型的上下文菜单行为(意味着在其他地方单击时菜单会关闭)。因此,如果您对如何解决这个问题有更好的建议,请以这种方式提示我!
编辑:
我成功了。弗兰克·奥斯特菲尔德的提示确实很有用。我仍然必须在创建(需要)握把菜单的小部件“A”中添加“gripmenu->activate()”,因为没有它,释放鼠标后活动小部件仍然是“A”。
我的.csv文件以逗号分隔,这是read_csv的标准设置.
这是有效的:
T1 = pd.DataFrame(pd.read_csv(loggerfile, header = 2)) #header contains column "1"
Run Code Online (Sandbox Code Playgroud)
但是一旦我在DataFrame构造函数中添加了一些东西read_csv,我的所有值都会突然出现NaN.为什么?怎么解决这个?
datetimeIdx = pd.to_datetime( T1["1"] ) #timestamp-column
T2 = pd.DataFrame(pd.read_csv(loggerfile, header = 2), index = datetimeIdx)
Run Code Online (Sandbox Code Playgroud) 为什么我无法连接动作以在触发时调用该函数?我认为我已经理解了根据这个源的语法 ,声明可以直接调用函数.
void Traymenu::createMainContextMenu(){
QAction *actionNewNote = mainContextMenu.addAction("Test Func");
QObject::connect(actionNewNote,QAction::triggered,Traymenu::testFunc);
mainIcon.setContextMenu(&mainContextMenu);
}
void Traymenu::testFunc(){
printf("test func");
}
Run Code Online (Sandbox Code Playgroud)
错误:invalid use of non-static member function 'void QAction::triggered(bool)
^
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,有一个保存过程阻止了我的UI。优化还不够,因此QtConcurrent尽管语法看起来很简单,但我想使用来实现线程,但无法使其正常工作。
这就是现在的样子(原理):
Traymenu::Traymenu(QApplication *a){
//...
void save(){
//Get the savepath, choose if saving is necessary, and trigger saving
QString path = getSavePath();
saveNotes(path);
}
void saveNotes(QString savePath){
//save to the given path, takes quite a while, should be parallel
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试过的
Traymenu::Traymenu(QApplication *a){
//...
void save(){
//Get the savepath, choose if saving is necessary, and trigger saving
QString path = getSavePath();
QFuture<void> result = QtConcurrent(saveNotes, path); //ERROR
}
void saveNotes(QString savePath){
//save to the given path
} …Run Code Online (Sandbox Code Playgroud)