我想从列表中删除重复项,但我正在做的是不起作用:
List<Customer> listCustomer = new ArrayList<Customer>();
for (Customer customer: tmpListCustomer)
{
if (!listCustomer.contains(customer))
{
listCustomer.add(customer);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个通用的Collection
,我试图找出如何排序其中包含的项目.我尝试了一些东西,但我不能让它们中的任何一个工作.
我有两个字符串字段代表我的页面中的日期,我想比较这两个字段,以了解我的第一个日期<第二个日期.我怎样才能做到这一点?
<tr>
<td align="right">First Date: </td>
<td align="left"> <html:text name="addPublicationForm" styleId="firstDate" property="firstDate" maxlength="10"/></td>
</tr>
<tr>
<td align="right">Second Date: </td>
<td align="left"> <html:text name="addPublicationForm" styleId="secondDate" property="secondDate" maxlength="10"/></td>
</tr>
Run Code Online (Sandbox Code Playgroud) 我有一些pb.我想在java中将List转换为Collection
Collection<T> collection = new Collection<T>(mylList);
Run Code Online (Sandbox Code Playgroud)
但我有这个错误
无法实例化类型Collection
我有DB的名称是"Project"和集合名称是"sample"然后我使用mongoimport
命令插入一个JSON文件.
现在我编辑了相同的JSON文件.因此,如果要将相同的JSON文件导入到Collection,那么我就会遇到问题,例如创建了多个实例并且没有进行更新.
有没有办法更新或覆盖mongodb使用mongoimport
命令中已存在的数据?
请注意,我也尝试过使用--mode=upsert
flag:
./mongoimport --db Project --collection sample --mode=upsert --file /home/rule.json
Run Code Online (Sandbox Code Playgroud) 我的项目结构:
- src
- main
- java
- resources
| -hibernate.cfg.xml
| -log4j.properties
- config
| -dev
| | -hibernate.cfg.xml
| | -log4j.properties
Run Code Online (Sandbox Code Playgroud)
我用maven-war-plugin
maven过滤.
pom.xml中:
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profileVersion>DEV</profileVersion>
<filterFile>src/main/filters/filter-dev.properties</filterFile>
<configFolder>src/main/config/dev/</configFolder>
</properties>
</profile>
</profiles>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<filters>
<filter>src/main/filters/filter.properties</filter>
<filter>${filterFile}</filter>
</filters>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
<webResources>
<resource>
<directory>${configFolder}</directory>
<includes>
<include>log4j.properties</include>
<include>hibernate.cfg.xml</include>
</includes>
<targetPath>/WEB-INF/classes/</targetPath>
</resource>
</webResources>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
<execution>
<id>package-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
输出控制台: …
我已经构建了一个Spring-Boot
使用jwt
身份验证的应用程序.
<?xml version="1.0" encoding="UTF-8"?>
<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.diplie</groupId>
<artifactId>rest-api</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RC1</version>
</parent>
<properties>
<springfox-version>2.2.2</springfox-version>
<java.version>1.8</java.version>
<maven.test.skip>true</maven.test.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>LATEST</version>
</dependency>
<!-- Swagger 2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
</dependency>
</dependencies>
<dependencyManagement> …
Run Code Online (Sandbox Code Playgroud) java ×6
collections ×4
list ×2
compare ×1
date ×1
duplicates ×1
gzip ×1
jquery ×1
json ×1
jwt ×1
maven ×1
mongodb ×1
mongoimport ×1
sorting ×1
spring-boot ×1
tar ×1
tinymce ×1
unix ×1