我创建了一个简单的单元测试,但IntelliJ错误地将其突出显示为红色.将其标记为错误
没豆子?
如下所示,它通过了测试?那么必须是Autowired?
我希望实际停止并删除一个docker容器,如果它正在运行.这是一个构建脚本.
以下面的例子为例.如何在bash脚本中的NAMES列下停止并删除docker容器"rabbitmq".
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9909a5e2856f rabbitmq-image "/docker-entrypoint.s" 11 minutes ago Up 11 minutes 0.0.0.0:5672->5672/tcp, rabbitmq
8990dd1fe503 redis-image "/entrypoint.sh redis" 6 weeks ago Up 4 days 0.0.0.0:32770->6379/tcp redis
etc
Run Code Online (Sandbox Code Playgroud)
以下命令将删除容器并执行即将发生的操作
docker stop rabbitmq && docker rm -f rabbitmq
Run Code Online (Sandbox Code Playgroud)
然而它将它梳理成我想知道的脚本?我认为它看起来像这样.
#!/bin/bash
if [ /*docker ps check some value */ ]; then
docker stop rabbitmq && docker rm -f rabbitmq
fi
Run Code Online (Sandbox Code Playgroud) 当我运行我的单元测试时,它会调用我的计划任务.我想防止这种行为,这是由我@EnableScheduling
在主应用程序配置上的事实引起的.
如何在单元测试中禁用此功能?
我遇到过这个问题/答案,建议设置个人资料?
不确定我会怎么做?或者如果它有点矫枉过正?我正在考虑为我的单元测试使用单独的AppConfiguration,但是当我这样做时,感觉就像是重复代码两次?
@Configuration
@EnableJpaRepositories(AppConfiguration.DAO_PACKAGE)
@EnableTransactionManagement
@EnableScheduling
@ComponentScan({AppConfiguration.SERVICE_PACKAGE,
AppConfiguration.DAO_PACKAGE,
AppConfiguration.CLIENT_PACKAGE,
AppConfiguration.SCHEDULE_PACKAGE})
public class AppConfiguration {
static final String MAIN_PACKAGE = "com.etc.app-name";
static final String DAO_PACKAGE = "com.etc.app-name.dao";
private static final String ENTITIES_PACKAGE = "com.etc.app-name.entity";
static final String SERVICE_PACKAGE = "com.etc.app-name.service";
static final String CLIENT_PACKAGE = "com.etc.app-name.client";
static final String SCHEDULE_PACKAGE = "com.etc.app-name.scheduling";
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(){
// stripped code for question readability
}
// more app config code below etc
}
Run Code Online (Sandbox Code Playgroud)
单元测试示例.
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={AppConfiguration.class})
@Transactional …
Run Code Online (Sandbox Code Playgroud) 以下工作 - 当退单等于1时返回Y,否则默认为N.
IF(fd.charge_back = 1, 'Y', 'N') AS charge_back
Run Code Online (Sandbox Code Playgroud)
但是我似乎无法让这个工作?语法是否有效
IF(compliment = ('set' OR 'Y' OR 1), 'Y', 'N') AS customer_compliment
Run Code Online (Sandbox Code Playgroud) 我想重构我在一些代码中使用流的方式.第一个例子是我目前是如何做到的.第二个例子就是我试图让它看起来像.
Set<String> results = new HashSet<String>();
someDao.findByType(type)
.stream()
.forEach(t-> result.add(t.getSomeMethodValue()) );
Run Code Online (Sandbox Code Playgroud)
它看起来像这样吗?如果是这样我该怎么做呢?
Set<String> results = someDao.findByType(type)
.stream()
.collect( /* ?? no sure what to put here */ );
Run Code Online (Sandbox Code Playgroud) 如何将符号链接从一个目录复制到另一个目录?
ls -ls
file1.txt
file2.txt
files -> /mnt/iscsi-nfs-share/faulttracker-files
Run Code Online (Sandbox Code Playgroud)
我想要做的是将文件符号链接复制到另一个目录?
cp files /var/copylinktohere/
Run Code Online (Sandbox Code Playgroud)
上面的结果是cp:省略目录`files'
我通过以下命令安装了弹性搜索策展人.
sudo pip install -U elasticsearch-curator
Run Code Online (Sandbox Code Playgroud)
这一切都安装好了.
但是现在当我做以下事情时
curator_cli --version
Run Code Online (Sandbox Code Playgroud)
我得到以下依赖警告.
/usr/local/lib/python2.7/dist-packages/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
curator_cli, version 5.5.4
Run Code Online (Sandbox Code Playgroud)
如何修复警告或隐藏警告?
我希望使用PHP PDO进行多次插入.
我找到的最接近的答案是这一个
然而,给出的例子使用?? 而不是真正的占位符.
我已经查看了PHP doc站点上的占位符示例
php.net pdo.prepared-statements
$stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':value', $value);
Run Code Online (Sandbox Code Playgroud)
现在让我说我想实现上述但是使用数组
$valuesToInsert = array(
0 => array('name' => 'Robert', 'value' => 'some value'),
1 => array('name' -> 'Louise', 'value' => 'another value')
);
Run Code Online (Sandbox Code Playgroud)
如何使用PDO和每次交易多次插入?
我想它会以循环开始?
$stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)");
foreach($valuesToInsert as $insertRow){
// now loop through each inner array to match binded values
foreach($insertRow as $column …
Run Code Online (Sandbox Code Playgroud) 我有一个带弹簧靴的单页角度应用程序.它看起来如下
src
main
java
controller
HomeController
CustomerController
OtherController
webapp
js/angular-files.js
index.html
Run Code Online (Sandbox Code Playgroud)
Spring启动正确默认为webapp文件夹并提供index.html文件.
我要做的是
1) 对于每个本地REST请求,不以/ api覆盖开头并重定向到默认的webapp/index.html.我打算为弹簧控制器提供任何/ api服务.
2)有没有办法为所有控制器添加api前缀,这样我就不必每次都写api.
例如
@RequestMapping("/api/home") can write shorthand in code @RequestMapping("/home")
Run Code Online (Sandbox Code Playgroud)
要么
@RequestMapping("/api/other-controller/:id") can write shorthand @RequestMapping("/other-controller/:id")
Run Code Online (Sandbox Code Playgroud)
编辑.. 更多注释以上解释更好
我正在寻找每个api请求,例如1) http:// localhost:8080/api/home使用api保持api并解决纠正控制器并返回json.
但是,如果有人输入URL,如http:/// localhost/some-url 或http:/// localhost/some-other/123/url 那么它将提供index.html页面并保留URL.
替代方法 - 尝试添加#ErrorViewResolver Springboot/Angular2 - 如何处理HTML5网址?
混淆为什么我为以下代码获得重复的类错误?
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package database_console;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
*
* @author davidsonr
*/
public class DBConnect {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}
Run Code Online (Sandbox Code Playgroud)
Netbeans将DBConnect强调为红色,并出现重复的类错误.
java ×4
spring ×3
angular ×1
annotations ×1
autowired ×1
bash ×1
bulkinsert ×1
class ×1
collections ×1
command-line ×1
containers ×1
cp ×1
docker ×1
if-statement ×1
insert ×1
java-8 ×1
java-stream ×1
junit ×1
junit4 ×1
lambda ×1
linux ×1
mysql ×1
netbeans ×1
pdo ×1
php ×1
pip ×1
python ×1
select ×1
shell ×1
spring-boot ×1
spring-mvc ×1
sql ×1
symlink ×1
unit-testing ×1