- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想创建一个在 spring boot 上运行的小应用程序。当我将它打包成一个 jar 文件时,应用程序可以在我的本地机器上顺利运行。我决定将它部署在 AWS elastic beanstalk 上,所以我做了创建 .war 文件所需的更改 (https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html)
我想尝试在我本地的 TOMCAT 上运行它。所以我把war文件放在webapps目录下,运行Tomcat 8.0\bin\Tomcat8.exe
控制台中的日志看起来不错,甚至有一条信息表明 /hello
路由已被映射。服务器运行,但是当我输入 localhost:8080/hello 时,没有返回任何内容。没有错误,只是一个空白页面。
...........
rtInternal Starting Servlet Engine: Apache Tomcat/8.0.32
13-Feb-2016 23:57:32.965 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployWAR Deploying web application archive C:\Program Files\Apache
Software Foundation\Tomcat 8.0\webapps\superheroes-0.0.1-SNAPSHOT.war
13-Feb-2016 23:57:43.058 INFO [localhost-startStop-1] org.apache.jasper.servlet.
TldScanner.scanJars 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 scan
ned but no TLDs were found in them. Skipping unneeded JARs during scanning can i
mprove startup time and JSP compilation time.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.2.RELEASE)
2016-02-13 23:57:46.723 INFO 7804 --- [ost-startStop-1] com.ga1.SuperHeroesAppl
ication : Starting SuperHeroesApplication v0.0.1-SNAPSHOT on Kamil-PC
with PID 7804 (started by Kamil in C:\Program Files\Apache Software Foundation\T
omcat 8.0)
2016-02-13 23:57:46.734 INFO 7804 --- [ost-startStop-1] com.ga1.SuperHeroesAppl
ication : No active profile set, falling back to default profiles: def
ault
2016-02-13 23:57:47.076 INFO 7804 --- [ost-startStop-1] ationConfigEmbeddedWebA
pplicationContext : Refreshing org.springframework.boot.context.embedded.Annotat
ionConfigEmbeddedWebApplicationContext@1935808: startup date [Sat Feb 13 23:57:4
7 ICT 2016]; root of context hierarchy
2016-02-13 23:57:49.030 INFO 7804 --- [ost-startStop-1] o.s.b.f.s.DefaultListab
leBeanFactory : Overriding bean definition for bean 'beanNameViewResolver' w
ith a different definition: replacing [Root bean: class [null]; scope=; abstract
=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=tru
e; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.Err
orMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanN
ameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in c
lass path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfi
guration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null];
scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; auto
wireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.auto
configure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMet
hodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred);
defined in class path resource [org/springframework/boot/autoconfigure/web/WebM
vcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2016-02-13 23:57:49.775 INFO 7804 --- [ost-startStop-1] o.s.web.context.Context
Loader : Root WebApplicationContext: initialization completed in 2701
ms
2016-02-13 23:57:50.957 INFO 7804 --- [ost-startStop-1] b.a.w.TomcatWebSocketCo
ntainerCustomizer : NonEmbeddedServletContainerFactory detected. Websockets supp
ort should be native so this normally is not a problem.
2016-02-13 23:57:51.674 INFO 7804 --- [ost-startStop-1] o.s.b.c.e.ServletRegist
rationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-02-13 23:57:51.676 INFO 7804 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'errorPageFilter' to: [/*]
2016-02-13 23:57:51.677 INFO 7804 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-02-13 23:57:51.678 INFO 7804 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-02-13 23:57:51.680 INFO 7804 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-02-13 23:57:51.681 INFO 7804 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-02-13 23:57:52.361 INFO 7804 --- [ost-startStop-1] s.w.s.m.m.a.RequestMapp
ingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.cont
ext.embedded.AnnotationConfigEmbeddedWebApplicationContext@1935808: startup date
[Sat Feb 13 23:57:47 ICT 2016]; root of context hierarchy
2016-02-13 23:57:52.635 INFO 7804 --- [ost-startStop-1] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/superHero],methods=[POST]}" onto public org.sprin
gframework.http.ResponseEntity<java.lang.Void> com.ga1.superheroes.MainControlle
r.createSuperHero(com.ga1.superheroes.repository.RepositorySuperHero)
2016-02-13 23:57:52.639 INFO 7804 --- [ost-startStop-1] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/superHero],methods=[GET]}" onto public org.spring
framework.http.ResponseEntity<com.ga1.superheroes.repository.RepositorySuperHero
> com.ga1.superheroes.MainController.getSuperHero(java.lang.String)
2016-02-13 23:57:52.640 INFO 7804 --- [ost-startStop-1] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/superHeroes],methods=[GET]}" onto public org.spri
ngframework.http.ResponseEntity<java.util.List<java.lang.String>> com.ga1.superh
eroes.MainController.getSuperHeroes()
2016-02-13 23:57:52.641 INFO 7804 --- [ost-startStop-1] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/hello],methods=[GET]}" onto public org.springfram
ework.http.ResponseEntity<java.lang.String> com.ga1.superheroes.MainController.h
ello()
2016-02-13 23:57:52.654 INFO 7804 --- [ost-startStop-1] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.Res
ponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframewo
rk.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServ
letRequest)
2016-02-13 23:57:52.655 INFO 7804 --- [ost-startStop-1] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.spr
ingframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web
.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.serv
let.http.HttpServletResponse)
2016-02-13 23:57:52.733 INFO 7804 --- [ost-startStop-1] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class or
g.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-02-13 23:57:52.733 INFO 7804 --- [ost-startStop-1] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.spring
framework.web.servlet.resource.ResourceHttpRequestHandler]
2016-02-13 23:57:52.843 INFO 7804 --- [ost-startStop-1] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [clas
s org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-02-13 23:57:54.877 INFO 7804 --- [ost-startStop-1] org.mongodb.driver.clus
ter : Cluster created with settings {hosts=[localhost:27017], mode
=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWait
QueueSize=500}
2016-02-13 23:57:55.325 INFO 7804 --- [localhost:27017] org.mongodb.driver.conn
ection : Opened connection [connectionId{localValue:1, serverValue:16
}] to localhost:27017
2016-02-13 23:57:55.328 INFO 7804 --- [localhost:27017] org.mongodb.driver.clus
ter : Monitor thread successfully connected to server with descrip
tion ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED
, ok=true, version=ServerVersion{versionList=[3, 0, 5]}, minWireVersion=0, maxWi
reVersion=3, maxDocumentSize=16777216, roundTripTimeNanos=876166}
2016-02-13 23:57:55.549 INFO 7804 --- [ost-startStop-1] o.s.j.e.a.AnnotationMBe
anExporter : Registering beans for JMX exposure on startup
2016-02-13 23:57:55.590 INFO 7804 --- [ost-startStop-1] com.ga1.SuperHeroesAppl
ication : Started SuperHeroesApplication in 11.432 seconds (JVM runnin
g for 24.405)
13-Feb-2016 23:57:55.716 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployWAR Deployment of web application archive C:\Program Files\Ap
ache Software Foundation\Tomcat 8.0\webapps\superheroes-0.0.1-SNAPSHOT.war has f
inished in 22,750 ms
13-Feb-2016 23:57:55.721 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler ["http-nio-8080"]
13-Feb-2016 23:57:55.737 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler ["ajp-nio-8009"]
13-Feb-2016 23:57:55.742 INFO [main] org.apache.catalina.startup.Catalina.start
Server startup in 22911 ms
下面是我的:pom、controller 和 main 文件
<?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.ga1</groupId>
<artifactId>superheroes</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>superheroes</name>
<description>really super</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<!-- <tomcat.version>8.0.8</tomcat.version> -->
<!-- <start-class>com.ga1.SuperHeroesApplication</start-class> -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</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>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Controller :
package com.ga1.superheroes;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MainController {
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public ResponseEntity<String> hello() {
return new ResponseEntity<>("Hello World", HttpStatus.OK);
}
}
和主要的:
package com.ga1;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
@SpringBootApplication
public class SuperHeroesApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SuperHeroesApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SuperHeroesApplication.class);
}
}
最佳答案
我认为问题出在您使用的 URL 上。因为您现在是在独立的 Tomcat 上部署,所以您的 war 将部署在通常与 war 文件名匹配的上下文中,除非您在 application.properties 中指定了上下文。你能提供你的application.properties吗?
您可以这样在 application.properties 中设置上下文:
server.contextPath=/<whatever>
否则,我敢打赌您的 URL 将按原样访问:
/superheroes-0.0.1-SNAPSHOT/hello
关于java - 没有错误,但是映射不起作用 Spring boot + tomcat 8.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35382755/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!