私はこのような他の質問があることを知っていますが、私の問題は解決されません。春のブート+ MongoDB - localhostのホワイトリストのエラーを表示
私が間違っていることをお分かりいただければ幸いです。私は// localhostに行くとき
は:
<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.mycompany</groupId>
<artifactId>mavenproject1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>mavenproject1</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<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>7.0</version>
<scope>provided</scope>
</dependency>
<!--Spring-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.10.RELEASE</version>
</dependency>
<!--MONGO-->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.10.6.RELEASE</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<!--skal dette bruges?-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
と私のアプリケーションクラスがそうのようになります。8080私が得る "ホワイトレーベルのエラーを...."
私のpom.xmlは、次のようになります。
package com.example.mavenproject1;
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
/**
*
* @author Steffen
*/
@RestController
@EnableAutoConfiguration
@ComponentScan
public class Application {
//Run a function here which dives into the mongoDB and returns the info?
@RequestMapping("/")
String home() {
DBPopulator dbp = new DBPopulator();
dbp.saveNew();
// return dbp.getFil();
return "Hey wassup";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
そしてDBPopulator:
package com.example.mavenproject1;
import java.util.Date;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.context.support.GenericXmlApplicationContext;
/**
*
* @author Steffen
*/
public class DBPopulator {
ApplicationContext ctx = new AnnotationConfigApplicationContext(ConnectToDB.class);
MongoOperations mongoOperation = (MongoOperations) ctx.getBean("mongoTemplate");
private int vers = 0;
public void saveNew() {
Fil f = new Fil("fil" + vers + "", new MetaData(new Date(), new Date(), 5));
vers++;
mongoOperation.save(f);
};
public String getFil(){
// query to search user
Query searchQuery = new Query(Criteria.where("filNavn").is("fil1"));
Fil savedF = mongoOperation.findOne(searchQuery, Fil.class);
List<Fil> listFiler = mongoOperation.findAll(Fil.class);
System.out.println("Here is my file: " + savedF);
return "File: " + savedF;
}
}
今、私のアプリケーションは "work"と同じように新しい "Fil"をmongoDBに保存します。私はそれらをアプリケーションクラスの "Home"関数に戻したいと思っていましたが、これまでのところ、 "ホワイトラベルエラー"を出すことはできません...
ありがとうございます!
**
と// localhostのからの完全なエラー:8080がある:
ホワイトレーベルのエラーページ
あなたが、フォールバックとしてこれを見ているように、このアプリケーションは、のために/エラー明示的なマッピングを持っていません。 Mon Aug 07 16:39:18 CEST 2017 予期しないエラーが発生しました(type = Internal Server Error、status = 500)。 com/mongodb/BulkWriteException
コンソールからエラーメッセージとスタックトレース全体を貼り付けてください。 – zombie
こんにちは@zombie、エラーメッセージは次のようになります: Whitelabel Error Page このアプリケーションには/ errorの明示的なマッピングがないため、これをフォールバックとみなしています。 Mon Aug 07 16:39:18 CEST 2017 予期しないエラーが発生しました(type = Internal Server Error、status = 500)。 com/mongodb/BulkWriteException しかし、私はコンソールに何の出力も得ていません...なぜ大規模な助けになるか知っていれば! :) –