Reputation: 2271
I am trying to write a simple Java program that displays Hello World as a microservice. I am using Spring Boot, but due to security reasons at my company, I am unable to use Maven. Therefore, I have no option but to download the jar files and add them to my project. I have done so, and made sure I am using the latest jar versions. When I run my program, it shows no errors BUT Tomcat server is not starting and I do not see the "Hello World" message. Below is my code:
package com.tutorials;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@EnableAutoConfiguration
public class HelloWorld {
@RequestMapping("/")
//http://localhost:port/
String hello()
{
return "Hello World!";
}
public static void main(String[] args) throws Exception{
SpringApplication.run(HelloWorld.class,args);
System.out.println("done");
}
}
and below is the output:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.2.RELEASE)
2020-01-07 11:10:44.563 INFO 13224 --- [ main] com.tutorials.HelloWorld : Starting HelloWorld on HQTPM00184606D with PID 13224 (started by z.a in C:\Users\Z\Desktop\Workspace\HelloWorld_Microservice)
2020-01-07 11:10:44.566 INFO 13224 --- [ main] com.tutorials.HelloWorld : No active profile set, falling back to default profiles: default
2020-01-07 11:10:44.938 INFO 13224 --- [ main] com.tutorials.HelloWorld : Started HelloWorld in 0.703 seconds (JVM running for 1.096)
done
and below is the jar files I am using:
Why Tomcat is not starting and what dependencies I am missing here? Thanks.
Upvotes: 1
Views: 7552
Reputation: 10511
The dependency tree for spring-boot-starter-web 2.2.2 is:
org.springframework.boot:spring-boot-starter-web:jar:2.2.2.RELEASE:compile
+- org.springframework.boot:spring-boot-starter:jar:2.2.2.RELEASE:compile
| +- org.springframework.boot:spring-boot:jar:2.2.2.RELEASE:compile
| +- org.springframework.boot:spring-boot-autoconfigure:jar:2.2.2.RELEASE:compile
| +- org.springframework.boot:spring-boot-starter-logging:jar:2.2.2.RELEASE:compile
| | +- ch.qos.logback:logback-classic:jar:1.2.3:compile
| | | +- ch.qos.logback:logback-core:jar:1.2.3:compile
| | | \- org.slf4j:slf4j-api:jar:1.7.29:compile
| | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.12.1:compile
| | | \- org.apache.logging.log4j:log4j-api:jar:2.12.1:compile
| | \- org.slf4j:jul-to-slf4j:jar:1.7.29:compile
| +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
| +- org.springframework:spring-core:jar:5.2.2.RELEASE:compile
| | \- org.springframework:spring-jcl:jar:5.2.2.RELEASE:compile
| \- org.yaml:snakeyaml:jar:1.25:runtime
+- org.springframework.boot:spring-boot-starter-json:jar:2.2.2.RELEASE:compile
| +- com.fasterxml.jackson.core:jackson-databind:jar:2.10.1:compile
| | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.1:compile
| | \- com.fasterxml.jackson.core:jackson-core:jar:2.10.1:compile
| +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.10.1:compile
| +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.10.1:compile
| \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.10.1:compile
+- org.springframework.boot:spring-boot-starter-tomcat:jar:2.2.2.RELEASE:compile
| +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.29:compile
| +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.29:compile
| \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.29:compile
+- org.springframework.boot:spring-boot-starter-validation:jar:2.2.2.RELEASE:compile
| +- jakarta.validation:jakarta.validation-api:jar:2.0.1:compile
| \- org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:compile
| +- org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile
| \- com.fasterxml:classmate:jar:1.5.1:compile
+- org.springframework:spring-web:jar:5.2.2.RELEASE:compile
| \- org.springframework:spring-beans:jar:5.2.2.RELEASE:compile
\- org.springframework:spring-webmvc:jar:5.2.2.RELEASE:compile
+- org.springframework:spring-aop:jar:5.2.2.RELEASE:compile
+- org.springframework:spring-context:jar:5.2.2.RELEASE:compile
\- org.springframework:spring-expression:jar:5.2.2.RELEASE:compile
But as mentioned in the comments you should try to make the usage of build tools (Maven/Gradle) and a company-wide repository manager (Nexus/Artifactory) possible.
Upvotes: 2