gpt4 book ai didi

java - MongoDB 一些数据没有加载到 java tomcat 应用程序中

转载 作者:行者123 更新时间:2023-11-28 22:49:23 25 4
gpt4 key购买 nike

我不知道是什么导致了这个问题。本质上,我有一个连接到托管 mongo 数据库的 java webapp。我使用如下所示的新存储库向应用程序添加了一个新集合。

public interface ContractRepository extends PagingAndSortingRepository<Contract, String> {
public Contract findByNameIgnoreCase(String name);
public List<Contract> findByOwnerCompany(Company c);
}

一切正常数据被添加到数据库中,并被加载到应用程序中。然后我们推出了一个新版本,它不再从数据库中提取数据,但数据库中没有数据丢失。我手动添加了新记录,它们会正常显示。从那时起,我们手动添加了所有记录,并且在下一次更新之前一直运行良好。同样的问题。

POM:

http://maven.apache.org/maven-v4_0_0.xsd"> 公司网 申请人跟踪系统 1.0.0

<modelVersion>4.0.0</modelVersion>
<groupId>net.company.com</groupId>
<artifactId>ats-web</artifactId>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
<org.slf4j-version>1.7.7</org.slf4j-version>
<java-version>1.8</java-version>
<debug>true</debug>
</properties>
<dependencyManagement>
<dependencies>
<!-- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.6.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>net.acesinc.ats</groupId>
<artifactId>ats-model</artifactId>
<version>1.0.0-BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.company.com</groupId>
<artifactId>ats-resume-parser</artifactId>
<version>1.0.0</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- exclude their default logging logback so we can use log4j -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-spring-service-connector</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-cloudfoundry-connector</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>

<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>

<!-- include the log4j logger -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
</dependency>

<!-- Spring Data -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.9.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.6.1.RELEASE</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId>
<version>3.5.1</version>
</dependency>

<!-- Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.0.0.RELEASE</version>
<exclusions>
<!--Exclude Commons Logging in favor of SLF4j-->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.0.RELEASE</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.0.0.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>4.0.0.RELEASE</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.0.0.RELEASE</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.8-ea02</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>

<!-- Apache Commons file upload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.5</version>
</dependency>

<!-- Apache Commons IO -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<repositories>
<!-- These are set in the settings.xml to our nexus repo -->
</repositories>
<pluginRepositories>
<!-- These are set in the settings.xml to our nexus repo -->
</pluginRepositories>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
<!-- <plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.1.v20140609</version>
<configuration>
<systemPropertiesFile>${project.basedir}/src/main/resources/jetty/jetty.properties</systemPropertiesFile>
<jettyXml>${project.basedir}/src/main/resources/jetty/jetty.xml,${project.basedir}/src/main/resources/jetty/jetty-http.xml,${project.basedir}/src/main/resources/jetty/jetty-ssl.xml,${project.basedir}/src/main/resources/jetty/jetty-https.xml</jettyXml>
<jettyXml>${project.basedir}/src/main/resources/jetty/jetty.xml,${project.basedir}/src/main/resources/jetty/jetty-http.xml</jettyXml>
<war>${project.build.directory}/${project.build.finalName}</war>
<scanIntervalSeconds>1</scanIntervalSeconds>
</configuration>
</plugin>-->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<systemProperties>
<spring.profiles.active>dev</spring.profiles.active>
</systemProperties>
<path>/</path>
<url>http://localhost:1234/mymanager</url>
</configuration>
</plugin>
</plugins>
</build>

如有任何建议,我们将不胜感激。

最佳答案

如果 Contract 的结构发生变化,则可能是数据库中存在的旧数据具有不同的结构,无法加载到类 Contract 的实例中。

检查Contract的旧值和Contract的新值的json结构,看看是否有差异。

或者,如果您可以控制 Contract 类,请检查旧版本的 Contract 和新版本,看看数据是否兼容。

想象一下,例如,如果公司名称已从

重构
private String companyName;

private String name;

你不能用这个方法提取旧数据

public Contract findByNameIgnoreCase(String name);

关于java - MongoDB 一些数据没有加载到 java tomcat 应用程序中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45374845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com