成功部署项目后,页面未找到错误

时间:2020-02-26 11:26:12

标签: spring-boot deployment

我从命令提示符下部署了我的spring boot项目。它成功创建了WAR文件,但是当我尝试使用命令“ Catalina.bat run”运行它时,我只看到tomcat服务器在端口上打开,而我却无法执行CRUD操作,而我的代码在部署之前运行良好。 因此,请对此提出一些解决方案。 预先谢谢你。

Main.java

package jdbc_conn;

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

@SpringBootApplication
public class JdbcConnection
{

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

    }


}   

Controller.java

package jdbc_conn;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JdbcOperation {
    @Autowired
    JdbcTemplate jdbc;

    @RequestMapping("/insert")
    public String insert() {
        jdbc.execute("insert into student( Name, Contact) values ('Sanket','7588832088')");
        return "data Inserted Successfully";

    }

    @RequestMapping("/delete")
    public String Delete() {
        jdbc.execute("delete from student where Roll_No=2");
        return "Data Deleted Successfully";

    }

    @RequestMapping("/update")
    public String update() {
        jdbc.execute("update  student set Name='Santosh' where Roll_no=1");
        return "Data Update Successfully";

    }
}

Pom.xml

<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>Trixware.mrp</groupId>
  <artifactId>Array</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>ArrayShow</name>

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

    <properties>
    <downloadsources>true</downloadsources>
    <downloadjavadocs>true</downloadjavadocs>
        <java.version>1.8</java.version>

    </properties>
<dependencies>
 <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
      </dependency>


  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
  </dependency> 

       <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>



      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-tomcat</artifactId>
         <scope>provided</scope>
      </dependency>
      <dependency>
         <groupId>org.apache.tomcat.embed</groupId>
         <artifactId>tomcat-embed-jasper</artifactId>
         <scope>provided</scope>
      </dependency>



          </dependencies>

</project>

0 个答案:

没有答案