`
wiselyman
  • 浏览: 2080855 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
博客专栏
Group-logo
点睛Spring4.1
浏览量:81077
74ae1471-94c5-3ae2-b227-779326b57435
点睛Spring MVC4...
浏览量:130130
社区版块
存档分类
最新评论

Spring Boot由jar包转成war包

阅读更多

spring boot 默认是以jar包形式启动web程序,在新建spring boot项目时候可以选择war包的启动方式。

 

建议在开发的时候建立以jar包启动的web项目,启动效率更快,此时如果想发布成war包形式部署,做如下操作:

1.修改pom.xml

<packaging>jar</packaging>

 

修改成

<packaging>war</packaging>

 

2.新增如下到pom.xml文件中

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

 

3.新增ServletInitializer类

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(Application.class);
	}

}

 

新书推荐《JavaEE开发的颠覆者: Spring Boot实战》,涵盖Spring 4.x、Spring MVC 4.x、Spring Boot企业开发实战。

 

京东地址:http://item.jd.com/11894632.html

当当地址:http://product.dangdang.com/23926195.html

亚马逊地址:http://www.amazon.cn/图书/dp/B01D5ZBFUK/ref=zg_bsnr_663834051_6 

淘宝地址:https://item.taobao.com/item.htm?id=528426235744&ns=1&abbucket=8#detail

 

或自己在京东、淘宝、亚马逊、当当、互动出版社搜索自选。

 


6
0
分享到:
评论
17 楼 农村外出务工男JAVA 2017-03-05  
遇到了和大家一样的问,转成war后,,访问404,至今网上没找到解决方案,采用springboot 1.4.3 + jersey 2.x + tomcat 7
16 楼 nnxiaod 2017-03-01  
306274163 写道
  各位问题解决了吗?我也是JAR转成WAR,启动正常该问404



82.2 Create a deployable war file for older servlet containers

Older Servlet containers don’t have support for the ServletContextInitializer bootstrap process used in Servlet 3.0. You can still use Spring and Spring Boot in these containers but you are going to need to add a web.xml to your application and configure it to load an ApplicationContext via a DispatcherServlet.

以上是官方文档,如果你用的是servlet3.0以下的版本(tomcat7以下),是要添加web.xml的,还是升级到tomocat7吧,最简单了。。。
15 楼 306274163 2017-02-08  
  各位问题解决了吗?我也是JAR转成WAR,启动正常该问404
14 楼 fanxl12 2016-12-30  
正确配置如下:
@SpringBootApplication
public class TesttomcatApplication extends SpringBootServletInitializer {

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(TesttomcatApplication.class);
	}

//	@Override  复制官方文档上的方法,Application直接导入进去了,实际上应该是TesttomcatApplication
//	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
//		return application.sources(Application.class);
//	}

	public static void main(String[] args) {
		SpringApplication.run(TesttomcatApplication.class, args);
	}
}
13 楼 fanxl12 2016-12-30  
fanxl12 写道
按照文档,把jar改成war,tomcat启动就报错了,访问404,org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/testtomcat-0.0.1-SNAPSHOT]]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'application': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javafx.application.Application]: Is it an abstract class?; nested exception is java.lang.InstantiationException
不知道哪里出问题了,求解决

解决了自己的问题,看着官方文档配置,自己直接复制过来,没想到官方用的application.sources(Application.class)的Application类直接导入进去了,实际上应该是用自己的类名,望大家不要入坑
12 楼 fanxl12 2016-12-30  
lengyue1127 写道
博主的书我买了也基本看完了,很多测试也做了,基本例子都能调通,但是卡在war包发布这里了,我在网上也查了很多资料,包括官网也看了看。这个问题卡了一周了,不管怎么访问都是404。进不了controller。贴上我代码的信息,博主给的源码也下载和看了,我看很多评论也是卡在这里,博主能看看这个问题吗?

这个是代码入口。
import org.springframework.boot.web.support.SpringBootServletInitializer;

@SpringBootApplication
public class TestWarApplication extends SpringBootServletInitializer{
	
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(TestWarApplication.class);
	}

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


这个是controller
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WarController {
	@RequestMapping("/sayHello")
	public String sayHello() {
		return "sayHello";
	}
}


这个是porm.xml 配置
<?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>com.lengyue</groupId>
	<artifactId>com.lengyue</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>

	<name>TestWar</name>
	<description>Demo</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.4.0.RELEASE</version>
		<relativePath /> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<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-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-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>


这个是启动日志
  .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v1.4.0.RELEASE)

2016-09-21 16:22:10.937  INFO 2275 --- [ost-startStop-1] com.lengyue.TestWarApplication           : Starting TestWarApplication v0.0.1-SNAPSHOT on localhost with PID 2275 (/Users/Kandom/Desktop/Spring_Tool_Suite/pivotal-tc-server-developer-3.1.5.RELEASE/base-instance/wtpwebapps/TestWar/WEB-INF/classes started by Kandom in /Users/Kandom/Desktop/Spring_Tool_Suite/STS.app/Contents/MacOS)
2016-09-21 16:22:10.942  INFO 2275 --- [ost-startStop-1] com.lengyue.TestWarApplication           : No active profile set, falling back to default profiles: default
2016-09-21 16:22:10.993  INFO 2275 --- [ost-startStop-1] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4012eeb: startup date [Wed Sep 21 16:22:10 CST 2016]; root of context hierarchy
2016-09-21 16:22:11.793  INFO 2275 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 801 ms
2016-09-21 16:22:12.285  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2016-09-21 16:22:12.286  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'errorPageFilter' to: [/*]
2016-09-21 16:22:12.286  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-09-21 16:22:12.287  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-09-21 16:22:12.287  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-09-21 16:22:12.287  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2016-09-21 16:22:12.587  INFO 2275 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4012eeb: startup date [Wed Sep 21 16:22:10 CST 2016]; root of context hierarchy
2016-09-21 16:22:12.661  INFO 2275 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/sayHello]}" onto public java.lang.String com.lengyue.controller.WarController.sayHello()
2016-09-21 16:22:12.665  INFO 2275 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-09-21 16:22:12.665  INFO 2275 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-09-21 16:22:12.692  INFO 2275 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-21 16:22:12.692  INFO 2275 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-21 16:22:12.730  INFO 2275 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-21 16:22:12.852  INFO 2275 --- [ost-startStop-1] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-09-21 16:22:12.866  INFO 2275 --- [ost-startStop-1] com.lengyue.TestWarApplication           : Started TestWarApplication in 2.539 seconds (JVM running for 4.375)
2016-09-21 16:22:12.940  INFO 2275 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2016-09-21 16:22:12.982  INFO 2275 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
九月 21, 2016 4:22:12 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 3601 ms


我在本地是这样访问的
http://localhost:8080/TestWar/sayHello

一直报404的错误。

我这边也是,望解决
11 楼 fanxl12 2016-12-30  
按照文档,把jar改成war,tomcat启动就报错了,访问404,org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/testtomcat-0.0.1-SNAPSHOT]]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'application': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javafx.application.Application]: Is it an abstract class?; nested exception is java.lang.InstantiationException
不知道哪里出问题了,求解决
10 楼 IT小将 2016-12-29  
8楼的问题解决了吗?我也遇到这个问题了
9 楼 zhaoyaoniwo 2016-12-13  
把restcontroller换成controller
8 楼 lengyue1127 2016-09-21  
博主的书我买了也基本看完了,很多测试也做了,基本例子都能调通,但是卡在war包发布这里了,我在网上也查了很多资料,包括官网也看了看。这个问题卡了一周了,不管怎么访问都是404。进不了controller。贴上我代码的信息,博主给的源码也下载和看了,我看很多评论也是卡在这里,博主能看看这个问题吗?

这个是代码入口。
import org.springframework.boot.web.support.SpringBootServletInitializer;

@SpringBootApplication
public class TestWarApplication extends SpringBootServletInitializer{
	
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(TestWarApplication.class);
	}

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


这个是controller
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WarController {
	@RequestMapping("/sayHello")
	public String sayHello() {
		return "sayHello";
	}
}


这个是porm.xml 配置
<?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>com.lengyue</groupId>
	<artifactId>com.lengyue</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>

	<name>TestWar</name>
	<description>Demo</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.4.0.RELEASE</version>
		<relativePath /> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<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-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-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>


这个是启动日志
  .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v1.4.0.RELEASE)

2016-09-21 16:22:10.937  INFO 2275 --- [ost-startStop-1] com.lengyue.TestWarApplication           : Starting TestWarApplication v0.0.1-SNAPSHOT on localhost with PID 2275 (/Users/Kandom/Desktop/Spring_Tool_Suite/pivotal-tc-server-developer-3.1.5.RELEASE/base-instance/wtpwebapps/TestWar/WEB-INF/classes started by Kandom in /Users/Kandom/Desktop/Spring_Tool_Suite/STS.app/Contents/MacOS)
2016-09-21 16:22:10.942  INFO 2275 --- [ost-startStop-1] com.lengyue.TestWarApplication           : No active profile set, falling back to default profiles: default
2016-09-21 16:22:10.993  INFO 2275 --- [ost-startStop-1] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4012eeb: startup date [Wed Sep 21 16:22:10 CST 2016]; root of context hierarchy
2016-09-21 16:22:11.793  INFO 2275 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 801 ms
2016-09-21 16:22:12.285  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2016-09-21 16:22:12.286  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'errorPageFilter' to: [/*]
2016-09-21 16:22:12.286  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-09-21 16:22:12.287  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-09-21 16:22:12.287  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-09-21 16:22:12.287  INFO 2275 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2016-09-21 16:22:12.587  INFO 2275 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4012eeb: startup date [Wed Sep 21 16:22:10 CST 2016]; root of context hierarchy
2016-09-21 16:22:12.661  INFO 2275 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/sayHello]}" onto public java.lang.String com.lengyue.controller.WarController.sayHello()
2016-09-21 16:22:12.665  INFO 2275 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-09-21 16:22:12.665  INFO 2275 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-09-21 16:22:12.692  INFO 2275 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-21 16:22:12.692  INFO 2275 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-21 16:22:12.730  INFO 2275 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-21 16:22:12.852  INFO 2275 --- [ost-startStop-1] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-09-21 16:22:12.866  INFO 2275 --- [ost-startStop-1] com.lengyue.TestWarApplication           : Started TestWarApplication in 2.539 seconds (JVM running for 4.375)
2016-09-21 16:22:12.940  INFO 2275 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2016-09-21 16:22:12.982  INFO 2275 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
九月 21, 2016 4:22:12 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 3601 ms


我在本地是这样访问的
http://localhost:8080/TestWar/sayHello

一直报404的错误。
7 楼 ikinger 2016-09-17  
同样遇到了和一楼同样的问题,访问加上了项目名,index.jsp可以正常访问,就是访问不了controller,不知道为什么,已经困扰很久了。
6 楼 paker1989 2016-08-11  
kucoll 写道
我用spring boot打war包打好了,也部署了,但其中的rest API都是404,是这么回事。
另外你这个类用放在哪里? 随便扔就行了,还是需要在哪里引用这个文件?



请求加上项目名
5 楼 onepieceshin 2015-11-25  
终于找到打包成war部署到tomcat去了,
楼主,我想问为什么要这样才行呢?
4 楼 wiselyman 2015-10-16  
somefuture 写道
这么做的目的是什么?jar和war的优劣势是什么呢


是对目前流行的微服务的响应
3 楼 somefuture 2015-10-07  
这么做的目的是什么?jar和war的优劣势是什么呢
2 楼 wiselyman 2014-11-03  
kucoll 写道
我用spring boot打war包打好了,也部署了,但其中的rest API都是404,是这么回事。
另外你这个类用放在哪里? 随便扔就行了,还是需要在哪里引用这个文件?

放在和Application.java一个目录下
1 楼 kucoll 2014-11-02  
我用spring boot打war包打好了,也部署了,但其中的rest API都是404,是这么回事。
另外你这个类用放在哪里? 随便扔就行了,还是需要在哪里引用这个文件?

相关推荐

    mybatis-spring-boot-starter-2.1.4.jar

    mybatis-spring-boot-starter-2.1.4.jarmybatis-spring-boot-starter-2.1.4.jar

    spring boot 高清带目录手册

    Spring Boot 使创建独立的、产品级的、基于Spring的应用变得更容易,你只需要运行run即可...你可以使用Spring Boot创建Java应用,用java-jar或更传统的war包来部署应用。我们也提供了运行”Spring脚本”的命令行工具。

    详解Spring Boot 部署jar和war的区别

    本篇文章主要介绍了详解Spring Boot 部署jar和war的区别,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

    解决spring boot + jar打包部署tomcat 404错误问题

    1.spring boot 不支持jsp打jar包,jsp只能打war包. 方法: &lt;packaging&gt;war &lt;groupId&gt;org.springframework.boot &lt;artifactId&gt;spring-boot-maven-plugin 2.tomcat版本不能太新,太新容易不...

    gradle spring-boot demo JSP打WAR包

    用gradle在搭建spring-boot,实现restful,跳转JSP,打成WAR包发布到项目

    Spring Boot打包war jar 部署tomcat

    主要介绍了Spring Boot打包war jar 部署tomcat的相关资料,需要的朋友可以参考下

    Spring Boot+maven打war包的方法

    主要介绍了Spring Boot+maven打war包的方法,本文通过实例代码相结合的形式给大家介绍的非常详细,需要的朋友参考下吧

    2.0.2_Spring Boot 2 官方指导手册译文.docx

    Spring Boot 2 官方指导手册译文 ...您可以使用 Spring Boot 来创建 Java 应用程序,这些应用程序可以通过使用 java -jar或更传统的 war 部署来启动。我们还提供了一个运行“spring 脚本”的命令行工具。

    基于spring boot的爬虫系统,优秀毕业设计,计算机必看!

    一. 简介 通过 spring boot 搭建的爬虫系统 ...&gt; 方式二: maven打成jar包后,将使用命令 `java -jar spider-1.0.0-SNAPSHOT.war &` 启动spider-1.0.0-SNAPSHOT.war &gt; 方式三: 部署在tomcat中直接运行

    spring boot官方文档

    希望对大家有帮助,Spring Boot可以基于Spring轻松创建可以“运行”的、独立的、生产级的应用程序。 对Spring平台和第三方类库...您可以使用Spring Boot创建可以使用java -jar或传统 war 包部署启动的Java应用程序。

    springboot_jsp_maven(war+jar).rar

    一个基于springboot + jsp的demo项目, 非常简洁,可通过maven一键构建,亮点是不仅可以war包方式运行,还可以可执行jar包方式运行(实现这个需要突破很多关键技术和限制...)

    spring-boot-reference.pdf

    您可以使用Spring Boot创建可以使用java -jar或更传统的war部署启动的Java应用程序 。我们还提供了一个运行“spring脚本”的命令行工具。 我们的主要目标是: 为所有Spring开发提供从根本上更快且可广泛访问的入门...

    SpringAll_wuyouzhuguli.tar.gz

    Spring Boot项目打包成war包 Linux下部署Spring Boot jar Spring Boot中使用Jsoup防御XSS攻击 Spring Boot异常处理 Spring Boot中使用过滤器和拦截器 Spring Boot整合MyBatis通用Mapper和PageHelper 深入学习Spring ...

    springboot打包jar和war包的教程图解

    主要介绍了springboot打包jar和war包的方法,本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

    spring-boot-中文参考指南

    Spring Boot使开发独立的,产品级别的基于Spring的应用变得非常简单,你只...你可以使用Spring Boot创建Java应用,并使用 java -jar 启动它或采用传统的war部署方式。我们也提供了一个运行"spring 脚本"的命令行工具。

    SpringBoot(非maven)下使用到的所有jar包

    Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring...网上很多教程都是基于maven情况下的,而很多小伙伴没有使用到maven,jar包就成了一个很大的问题,我这边整理了springboot所使用到的jar包

    spring-boot-features-demo:Spring Boot太棒了!

    和标准的基于war包的Web应用相比,Spring Boot应用可以直接以java -jar的方式运行,也就是说不再需要部署到一个独立的Web容器(比如Tomcat)中才能运行。其背后的运行机制简单来说就是,当一个Spring Boot应用启动时...

    xxl-job-admin-spring-boot:将xuxueli的xxl-job-admin改造到spring boot框架,公司在用

    xxl-job-admin-spring-boot简介xuxueli的xxl-job-admin默认为war包发布,需要放置到容器中,而spring boot “not war, just run jar!”的口号使我们早已习惯了java -jar 启动web服务的清爽简洁,因此我将xxl-job-...

    SpringBoot微服务

    Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Boot致力于在...

Global site tag (gtag.js) - Google Analytics