我在 MongoDB 数据库中有一个集合,它有一些数据,想根据日期(忽略时间)过滤和查找数据。
样本数据
{
"_id" : ObjectId("563a38173c2ab9248c02d89e"),
"jobId" : "oAEKMcCIJRIAAAFQbrAR6NDd",
"jobName" : "CheckSessions",
"jobDesc" : "Checks and deletes expired session data",
"jobType" : "Job",
"startTime" : "2015-11-04 00:00:01",
"endTime" : "2015-11-04 00:00:01",
"domainName" : "root",
"recurrencePeriod" : "60",
"recurrencePeriodDesc" : "HOURS(1)"
}
{
"_id" : ObjectId("563a38173c2ab9248c02d89f"),
"jobId" : "C6wKMcCIJXoAAAFQm78R6NCm",
"jobName" : "CheckSessions",
"jobDesc" : "Checks and deletes expired session data",
"jobType" : "Job",
"startTime" : "2015-11-03 23:00:00",
"endTime" : "2015-11-03 23:00:01",
"domainName" : "root",
"recurrencePeriod" : "60",
"recurrencePeriodDesc" : …Run Code Online (Sandbox Code Playgroud) 我有一个查询成功返回 ActiveRecord 中的结果。
select
trunc(b.transaction_date) as transaction_date,
sum(a.transaction_amount) as transaction_amount
from
payment_transaction a,
payment_settlement b
where
a.transaction_status = 'S'
and b.settlement_type = 'D'
and trunc(b.transaction_date) > sysdate - 30
and a.payment_transaction_id = b.payment_transaction_id
group by
trunc(b.transaction_date)
order by
trunc(b.transaction_date)
Run Code Online (Sandbox Code Playgroud)
上述查询返回 9 个结果。
我想要的是将上面获得的整个结果转换为哈希,例如:
{
"01/01/16" => 764.00,
"02/01/16" => 1508.00,
"03/01/16" => 2000.00
..
..
..
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现这个目标?
我想xmlns从以下xml字符串中删除属性。我已经编写了一个java程序,但是不确定它是否需要执行此处的操作。
如何删除xmlns属性并获取修改后的xml字符串?
输入XML字符串:
<?xml version="1.0" encoding="UTF-8"?>
<Payment xmlns="http://api.com/schema/store/1.0">
<Store>abc</Store>
</Payment>
Run Code Online (Sandbox Code Playgroud)
预期的XML输出字符串:
<?xml version="1.0" encoding="UTF-8"?>
<Payment>
<Store>abc</Store>
</Payment>
Run Code Online (Sandbox Code Playgroud)
Java类:
public class XPathUtils {
public static void main(String[] args) {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Payment xmlns=\"http://api.com/schema/store/1.0\"><Store>abc</Store></Payment>";
String afterNsRemoval = removeNameSpace(xml);
System.out.println("afterNsRemoval = " + afterNsRemoval);
}
public static String removeNameSpace(String xml) {
try {
System.out.println("before xml = " + xml);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource inputSource = new InputSource(new StringReader(xml));
Document …Run Code Online (Sandbox Code Playgroud) 我刚刚使用https://docs.docker.com/windows/step_one/中提供的说明在我的Windows 7机器上安装了Docker .
在安装过程中我没有安装Git,Virtual Box因为我已经在我的机器上安装了它们.安装后我修复了丢失的bash.exe脚本问题,并在某种程度上使docker工作.但我无法运行默认的hello-worlddocker命令.我收到了以下错误.
我已经研究了SO 故障排除中提到的类似问题.Tocker-On-Windows尝试运行hello-world但是我在这里遇到的错误是不同的.所以请不要将其标记为重复.
$ docker run hello-world
docker: An error occurred trying to connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.23/containers/create: open //./pipe/docker_engine: The system cannot find the file specified..
See 'docker run --help'.
$ docker version
Client:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 21:20:08 2016
OS/Arch: windows/amd64
An error occurred trying to connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.23/version: open //./pipe/docker_engine: The …Run Code Online (Sandbox Code Playgroud) 我无法通过 Spring Boot 从属性文件中读取属性。我有一个 REST 服务,它通过浏览器和邮递员工作,并向我返回一个有效的 200 响应数据。
但是,我无法使用 @Value 注释通过此 Spring Boot 客户端读取属性并获得以下异常。
例外:
helloWorldUrl = null
Exception in thread "main" java.lang.IllegalArgumentException: URI must not be null
at org.springframework.util.Assert.notNull(Assert.java:115)
at org.springframework.web.util.UriComponentsBuilder.fromUriString(UriComponentsBuilder.java:189)
at org.springframework.web.util.DefaultUriTemplateHandler.initUriComponentsBuilder(DefaultUriTemplateHandler.java:114)
at org.springframework.web.util.DefaultUriTemplateHandler.expandInternal(DefaultUriTemplateHandler.java:103)
at org.springframework.web.util.AbstractUriTemplateHandler.expand(AbstractUriTemplateHandler.java:106)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:612)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:287)
at com.example.HelloWorldClient.main(HelloWorldClient.java:19)
Run Code Online (Sandbox Code Playgroud)
HelloWorldClient.java
public class HelloWorldClient {
@Value("${rest.uri}")
private static String helloWorldUrl;
public static void main(String[] args) {
System.out.println("helloWorldUrl = " + helloWorldUrl);
String message = new RestTemplate().getForObject(helloWorldUrl, String.class);
System.out.println("message = " + message);
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序属性
rest.uri=http://localhost:8080/hello
Run Code Online (Sandbox Code Playgroud) GitLab API 的以下 REST Url 为我提供了项目的存储库树。
获取回购树(工作)
https://gitlab.gspt.net/api/v3/projects/2931/repository/tree?private_token=XXXX
Run Code Online (Sandbox Code Playgroud)
输出:
[
{
"id": "a49d11794ed56db7f935abfd61002aef67159d10",
"name": "src",
"type": "tree",
"path": "src",
"mode": "040000"
},
{
"id": "0fbd98527d4b36e3d22c164293d8fd8eee4d18cd",
"name": ".gitignore",
"type": "blob",
"path": ".gitignore",
"mode": "100644"
},
{
"id": "0ef0da472176f2e6a24843ac9d4bb738c8310d23",
"name": "pom.xml",
"type": "blob",
"path": "pom.xml",
"mode": "100644"
}
]
Run Code Online (Sandbox Code Playgroud)
但我无法获得文件的原始内容,确切地说是 pom.xml。
获取文件的原始内容(不起作用 - 给出 404)
https://gitlab.gspt.net/api/v3/projects/2931/repository/files/pom%2Exml/raw?private_token=xxxx&ref_name=master
Run Code Online (Sandbox Code Playgroud)
输出:
{
"error": "404 Not Found"
}
Run Code Online (Sandbox Code Playgroud)
根据此处的文档(https://docs.gitlab.com/ee/api/repository_files.html#get-raw-file-from-repository),我指定了正确的 rest url。然而,唯一不同的是在其余 api 端点中使用 V4 而不是 V3。我四处搜索,但找不到 v3 api 的端点。
无法WebDriver正确配置,因此我的功能测试失败UI。
我查看了这两个 SO 链接,但不确定如何使用geckodriver.exehere 以及它的目的是什么。
我还寻找了一些在线教程,其中Selenium配置了Spring Boot但其中大部分都使用旧版本的 Spring。
更新:
IEDriverServer.exe在C:\FAST目录中。 System.getProperty并指向它的位置来修改代码库IEDriverServer.exe任何指导都会有所帮助。
pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-ie-driver</artifactId>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
src/main/java/Application.java
@SpringBootApplication
public class Application {
public static void main(String[] args) { …Run Code Online (Sandbox Code Playgroud) 我有一个非常基本的Spring Boot应用程序,schema.sql它分别data.sql创建H2 DB模式和导入数据。
我的schema生成正常,H2 DB但由于某种原因,数据没有导入。我看到0表中的记录。
我也没有看到任何错误。
看起来像是配置问题。请指导。
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
应用程序属性
hibernate.jdbc.batch_size=500
hibernate.show_sql=true
hibernate.format_sql=true
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:tcp://localhost/~/h2-dbs/demo-db
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
Run Code Online (Sandbox Code Playgroud)
src/main/resources/schema.sql
drop table env if exists;
create table env (
id int auto_increment primary key,
name varchar(250) not null default 'DEV',
category varchar(250) not null default …Run Code Online (Sandbox Code Playgroud) 我想使用maven-tomcat插件在远程定位的Tomcat上部署WAR.但是遇到问题并获得异常(如下所述).请指导.
mvn tomcat:redeploy
Run Code Online (Sandbox Code Playgroud)
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project PageNameService: Cannot invoke Tomcat manager: Connection refused: connect - [Help 1]
Run Code Online (Sandbox Code Playgroud)
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>UnixTomcatServer</id>
<username>manager</username>
<password>manager</password>
</server>
</servers>
</settings>
Run Code Online (Sandbox Code Playgroud)
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="manager" password="manager" roles="manager-gui,manager-script,admin" />
Run Code Online (Sandbox Code Playgroud)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.study.apigee</groupId>
<artifactId>PageNameService</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>PageNameService</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> …Run Code Online (Sandbox Code Playgroud) 如何从Nexus自动部署战争到Tomcat?
我有一个maven web项目,可以在Nexus上成功构建和部署(SNAPSHOT和发布版本).我想知道Nexus中是否有功能/插件,它会选择已发布的战争并自动部署在远程Tomcat上?
我知道您可以使用maven-tomcat-plugin将战争部署到远程Tomcat,但是想知道是否有替代解决方案.
请指导.
java ×5
spring-boot ×3
maven ×2
rest ×2
spring ×2
tomcat ×2
activerecord ×1
docker ×1
git ×1
gitlab ×1
h2 ×1
maven-plugin ×1
mongodb ×1
nexus ×1
ruby ×1
selenium ×1
spring-data ×1
spring-mvc ×1
stax ×1
windows ×1
xml ×1