Page 1 of 1

Localhost:8080

PostPosted: 28. April 2019 10:35
by KT27
I create Restful web service using intelliJ IDEA and mysql(XAMPP). Program was run correctly but http://localhost:8080/demo/all this URL did not work. Please help me friends.

Re: Localhost:8080

PostPosted: 28. April 2019 11:00
by Altrea
How should we be able to help you?
We don't know anything about your web service and its configuration.
We don't know any error message or error code.
We don't know anything about the contents of your log files.

Re: Localhost:8080

PostPosted: 29. April 2019 09:59
by KT27
This is my java code
Code: Select all
package pizzaloop;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity

public class PizzaDetails {
    @Id
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Integer id;
    private String name;
    private String description;
    private Double price;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }
}



This is my main controller java code
Code: Select all
package pizzaloop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(path="/demo")
public class MainController {

    @Autowired

    private PizzaRepository pizzaRepository;
    @GetMapping(path="/all")

    public @ResponseBody
    Iterable<PizzaDetails> getPizzaDetails() {
        return pizzaRepository.findAll();
    }
}


This is application Java code
Code: Select all
package pizzaloop;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication

public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }


}





this is maven code
Code: Select all
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>lk.ac.kln.rest</groupId>
    <artifactId>mysql-rest-service</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) -->

        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.7.1</version>
            <type>maven-plugin</type>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- Use MySQL Connector-J -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
    </dependencies>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>


project compile and it was run correctly. But browser not show my data base values in JSON format.
"http://localhost:8080/demo/all" this is not working.
please help me.

Re: Localhost:8080

PostPosted: 29. April 2019 11:44
by Nobbie
I dont think Xampp supports Maven. Due to Wikipedia you need "Apache Maven for executing IntelliJ IDEA. Unfortunately i cannot help any further, as i dont know IntelliJ IDEA neither Apache Maven, but surely i can say that Xampp does not deliver Apache Maven.

Re: Localhost:8080

PostPosted: 30. April 2019 10:00
by KT27
Thanks for the reply but we did at the university. Now I can't do it my PC. :(

Re: Localhost:8080

PostPosted: 30. April 2019 10:07
by Nobbie
Why dont you try to install Apache Maven? See https://maven.apache.org

Re: Localhost:8080

PostPosted: 30. April 2019 13:55
by KT27
Thanks. I installed it but still above problem. :cry:

Re: Localhost:8080

PostPosted: 30. April 2019 19:38
by Nobbie
The problem is, installing and running a webserver is a quite sophisticated task. Its not as simple as installing a game or so. Usually educated system administrators are doing that job. It requires lots of knowledge about TCPIP, HTTP, Java JRE etc. etc. etc. - you cannot simply click a button and everything is fine.

Ask in your university for support. They really should know what is needed and how to configure it.