I recently signed up for a free website and the URL is http://kensinelli.infinityfreeapp.com. I'm trying to learn Spring MVC, and rather than do everything on localhost:8080, I wanted to do everything on an actual website so that potential employers can easily see whatever I decide to create. However, I've been struggling to figure out how to accomplish this. I've Google'd quite a bit and found some resources mentioning the application.properties file, and I've set server.address = http://kensinelli.infinityfreeapp.com and server.port = 80. I've also tried setting server.address = 185.27.134.151 which is the stated IP address in the website control panel. When I use the IP address and try to start Spring, I get the error:
org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
When I use http://kensinelli.infinityfreeapp.com instead of the IP address I get this error:
Failed to bind properties under 'server.address' to java.net.InetAddress:
Property: server.address
Value: http://kensinelli.infinityfreeapp.com
Origin: class path resource [application.properties] - 1:16
Reason: failed to convert java.lang.String to java.net.InetAddress
Action:
Update your application's configuration
So I think server.address is supposed to be an actual IP address and not a named server address that would be run through a DNS.
But do I even need to do this through Spring's built-in Tomcat? Can I circumnavigate that somehow or is Tomcat required even to connect to external websites?
My files are currently as such:
package spring.project;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class WebProjectApplication {
public static void main(String[] args) {
SpringApplication.run(WebProjectApplication.class, args);
System.out.println("Hello world");
}
}
pom.xml (some dependencies are commented out because I plan on using them in the future but they were causing me errors upon startup for now):
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>spring.project</groupId>
<artifactId>webProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>webProject</name>
<description>spring project</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-jdbc</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-starter-thymeleaf</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.thymeleaf.extras</groupId> -->
<!-- <artifactId>thymeleaf-extras-springsecurity5</artifactId> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.postgresql</groupId> -->
<!-- <artifactId>postgresql</artifactId> -->
<!-- <scope>runtime</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.properties:
server.address=185.27.134.151
server.port=80
I understand that my code isn't doing anything at this point, but I'm just trying to get it to start without errors right now. I'm really new at this so please don't assume I know much of anything. A step-by-step walkthrough would be hugely appreciated. Please don't just say "Read the documentation" because I've already looked at it and either I'm not finding what I'm looking for or not understanding it, so I need someone to clarify. Thank you.
Aucun commentaire:
Enregistrer un commentaire