I have the following application.properties
spring.data.mongodb.uri=mongodb://localhost:8000
spring.data.mongodb.username=torben
spring.data.mongodb.host=localhost
spring.data.mongodb.database=te
And I have the following code
package com.example.demo3;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan(basePackages = {"com.example.demo3", "com.example.demo3.test"})
public class Demo3Application {
public static void main(String[] args) {
SpringApplication.run(Demo3Application.class, args);
}
But when I make a Requet with Postman and type http://localhost:8080/
I get the following Exception
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.2)
2023-08-02T01:00:40.649+02:00 INFO 68540 --- [ main] com.example.demo3.Demo3Application : Starting Demo3Application using Java 17.0.7 with PID 68540 (/home/t/Dokumente/demo3/target/classes started by t in /home/t/Dokumente/demo3)
2023-08-02T01:00:40.652+02:00 INFO 68540 --- [ main] com.example.demo3.Demo3Application : No active profile set, falling back to 1 default profile: "default"
2023-08-02T01:00:40.965+02:00 INFO 68540 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.
2023-08-02T01:00:40.974+02:00 INFO 68540 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 6 ms. Found 0 MongoDB repository interfaces.
2023-08-02T01:00:41.197+02:00 INFO 68540 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-08-02T01:00:41.203+02:00 INFO 68540 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-08-02T01:00:41.203+02:00 INFO 68540 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.11]
2023-08-02T01:00:41.263+02:00 INFO 68540 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-08-02T01:00:41.264+02:00 INFO 68540 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 579 ms
2023-08-02T01:00:41.490+02:00 INFO 68540 --- [ main] org.mongodb.driver.client : MongoClient with metadata {"driver": {"name": "mongo-java-driver|sync|spring-boot", "version": "4.9.1"}, "os": {"type": "Linux", "name": "Linux", "architecture": "amd64", "version": "5.15.0-78-generic"}, "platform": "Java/Eclipse Adoptium/17.0.7+7"} created with settings MongoClientSettings{readPreference=primary, writeConcern=WriteConcern{w=null, wTimeout=null ms, journal=null}, retryWrites=true, retryReads=true, readConcern=ReadConcern{level=null}, credential=null, streamFactoryFactory=null, commandListeners=[], codecRegistry=ProvidersCodecRegistry{codecProviders=[ValueCodecProvider{}, BsonValueCodecProvider{}, DBRefCodecProvider{}, DBObjectCodecProvider{}, DocumentCodecProvider{}, CollectionCodecProvider{}, IterableCodecProvider{}, MapCodecProvider{}, GeoJsonCodecProvider{}, GridFSFileCodecProvider{}, Jsr310CodecProvider{}, JsonObjectCodecProvider{}, BsonCodecProvider{}, EnumCodecProvider{}, com.mongodb.client.model.mql.ExpressionCodecProvider@2839e3c8, com.mongodb.Jep395RecordCodecProvider@66bf40e5]}, loggerSettings=LoggerSettings{maxDocumentLength=1000}, clusterSettings={hosts=[localhost:8000], srvServiceName=mongodb, mode=SINGLE, requiredClusterType=UNKNOWN, requiredReplicaSetName='null', serverSelector='null', clusterListeners='[]', serverSelectionTimeout='30000 ms', localThreshold='30000 ms'}, socketSettings=SocketSettings{connectTimeoutMS=10000, readTimeoutMS=0, receiveBufferSize=0, sendBufferSize=0}, heartbeatSocketSettings=SocketSettings{connectTimeoutMS=10000, readTimeoutMS=10000, receiveBufferSize=0, sendBufferSize=0}, connectionPoolSettings=ConnectionPoolSettings{maxSize=100, minSize=0, maxWaitTimeMS=120000, maxConnectionLifeTimeMS=0, maxConnectionIdleTimeMS=0, maintenanceInitialDelayMS=0, maintenanceFrequencyMS=60000, connectionPoolListeners=[], maxConnecting=2}, serverSettings=ServerSettings{heartbeatFrequencyMS=10000, minHeartbeatFrequencyMS=500, serverListeners='[]', serverMonitorListeners='[]'}, sslSettings=SslSettings{enabled=false, invalidHostNameAllowed=false, context=null}, applicationName='null', compressorList=[], uuidRepresentation=JAVA_LEGACY, serverApi=null, autoEncryptionSettings=null, contextProvider=null}
2023-08-02T01:00:41.502+02:00 INFO 68540 --- [-localhost:8000] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:8000, type=STANDALONE, state=CONNECTED, ok=true, minWireVersion=0, maxWireVersion=17, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=9443740}
2023-08-02T01:00:41.611+02:00 INFO 68540 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-08-02T01:00:41.618+02:00 INFO 68540 --- [ main] com.example.demo3.Demo3Application : Started Demo3Application in 1.172 seconds (process running for 1.365)
2023-08-02T01:02:15.267+02:00 INFO 68540 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-08-02T01:02:15.267+02:00 INFO 68540 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2023-08-02T01:02:15.268+02:00 INFO 68540 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
2023-08-02T01:02:15.275+02:00 ERROR 68540 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.http.InvalidMediaTypeException: Invalid mime type "application/": does not contain subtype after '/'] with root cause
org.springframework.util.InvalidMimeTypeException: Invalid mime type "application/": does not contain subtype after '/'
at org.springframework.util.MimeTypeUtils.parseMimeTypeInternal(MimeTypeUtils.java:232) ~[spring-core-6.0.11.jar:6.0.11]
What did I do wrong? Spring itself says that there is a http server via Tomcat at 8080.