“请求的资源不可用”在Tomcat

时间:2016-05-05 15:42:22

标签: java spring maven tomcat

我收到请求的资源()在浏览器中显示不可用,我无法理解我做错了什么。

我知道,关于这个问题的帖子太多但是我还是这个错误, 阅读官方文档对我没有帮助spring boot maven plugin

在IDE(嵌入式tomcat)上正常工作。

enter image description here

这是我的pom.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>netgloo</groupId>
<artifactId>spring-boot-mysql-hibernate</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>spring-boot-mysql-hibernate</name>
<description> Spring Boot web application with Hibernate Spatial</description>

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

<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-data-jpa</artifactId>
</dependency>
<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>9.4-1200-jdbc4</version>
</dependency>

  <dependency>
      <groupId>org.json</groupId>
      <artifactId>json</artifactId>
      <version>20160212</version>
  </dependency>

  <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-spatial</artifactId>
      <version>4.3</version>
  </dependency>
  <dependency>
      <groupId>org.postgis</groupId>
      <artifactId>postgis-jdbc</artifactId>
      <version>1.5.2</version>
  </dependency>
<dependency>
  <groupId>org.thymeleaf</groupId>
  <artifactId>thymeleaf-spring4</artifactId>
  <version>2.1.2.RELEASE</version>
</dependency>

</dependencies>

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <start-class>netgloo.Application</start-class>
  <java.version>1.7</java.version>
</properties>

<repositories>
 <repository>
  <id>OSGEO GeoTools repo</id>
  <url>http://download.osgeo.org/webdav/geotools</url>
 </repository>
 <repository>
  <id>Hibernate Spatial repo</id>
  <url>http://www.hibernatespatial.org/repository</url>
 </repository>
 <repository>
  <id>JBOSS</id>
  <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
 </repository>
 </repositories>

 <build>
  <plugins>
    <plugin>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-maven-plugin</artifactId>
   </plugin>
  <plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
   </plugin>
  </plugins>
  <finalName>kgeo</finalName>
</build>

</project>

主要应用类

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  return application.sources(Application.class);
  }
  public static void main(String[] args) {
  SpringApplication.run(Application.class, args);
}

}

主控制器

@Controller
public class MainController {

  @RequestMapping("/")
  public String index(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
  model.addAttribute("name", name);
  return "index";
  }

}

此示例工作没有问题java sample war

在Catalina日志中我可以看到错误

  

“引起:java.lang.NoSuchMethodError:java.util.concurrent.ConcurrentHashMap.keySet()Ljava / util / concurrent / ConcurrentHashMap $ KeySetView;”

阅读这个可以通过java版本的不匹配来生成,在我的编辑器中我从java8开始然后我下降到7,目前我正在使用maven3构建,使用open-jdk 7和Tomcat7相同

0 个答案:

没有答案