我的gradle构建存在问题.我使用Spring网站(https://spring.io/guides/gs/rest-service/)提出的标准,但是当我尝试使用gradle build时,我收到了这个错误:

它不适用于这个gradle,但是当我使用另一个(我在学校时使用的)它完美地工作.
我正在尝试启动一个简单的spring应用程序
我在这里有main.java文件:
package main;
import javafx.application.Application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan
@EnableAutoConfiguration
public class Main {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的libs:

这是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>blog</groupId>
<artifactId>blog</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
最后错误就是这个:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ …Run Code Online (Sandbox Code Playgroud) 我正在使用Spring Security OAuth2.客户端应用程序(我们拥有)发出"密码"授权请求,该请求传递用户的用户名和密码.就像草案规定的一样.
我需要这种机制来支持其他类型的凭证,例如卡号,PIN,甚至是预先认证的,不需要密码的授权.
请记住,这些请求只能由特权client_id允许,该特权client_id只能从我们拥有的应用程序中使用.
我正在尝试使用Webjars将jQuery添加到我的Boot应用程序中.我从本教程中获得灵感:http: //spring.io/blog/2014/01/03/utilizing-webjars-in-spring-boot
在我的pom.xml中,我添加了:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>2.1.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在我的html文件中(使用ThymeLeaf作为我的模板引擎 - 不确定这是否重要)我有以下内容:
<script src="webjars/jquery/2.1.1/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
该文件未加载.我试过src ="webjars ...."和src ="/ webjars ...".
我可以看到我项目中列出的Maven依赖项中的jar.当我探索这个jar时,我可以看到META-INF/resources/webjars/jquery/2.1.1/jquery.min.js.根据我如何理解Boot寻找资源,我认为它应该找到这个.
有人看到这种行为吗?如何解决它的任何提示?
我正在使用intellij并且所有spring的插件都被激活,如何将spring-boot注释配置类添加到intellij IDE.我正在关注警告:
Spring配置检查找到未映射的Spring配置文件.请为模块配置/设置Spring facet:exampleApp(13个文件)
我试图从Spring Boot运行Hello World示例.当我在模块上运行'mvn package'时,我收到以下错误: -
[错误]无法执行目标org.apache.maven.plugins:maven-shade-plugin:2.1:项目上的shade(默认)spring.boot:无法解析mojo的配置org.apache.maven.plugins:maven-> shade-> plugin:2.1:参数变换器的阴影:在'资源'的org.apache.maven.plugins.shade.resource.ManifestResourceTransformer中找不到setter,adder和field字段 - > [Help 1]
我没有使用任何"资源"属性,但它似乎抱怨这一点.知道我在这里做错了什么
这是模块的pom: -
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>spring.boot</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>hello.SampleController</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 mvn package 命令编译 Spring Boot 项目,但出现此错误。我相信我已经安装了 JDK 1.7_55。
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.144s
[INFO] Finished at: Fri May 16 11:57:18 EST 2014
[INFO] Final Memory: 8M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project m
yproject: Compilation failure
[ERROR] No …Run Code Online (Sandbox Code Playgroud) throwExceptionIfNoHandlerFoundDispatcherServlet在 Spring 4.0 中引入。
我试图弄清楚如何在DispatcherServletSpring Boot 提供的自动配置中设置这个属性,但没有运气。
一些挖掘表明下面的代码段应该有效,但事实并非如此。
@Bean
public ServletContextInitializer servletContextInitializer() {
return new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("throwExceptionIfNoHandlerFound", "true");
}
};
}
Run Code Online (Sandbox Code Playgroud) 我有一个带有嵌入式 tomcat 的 spring-boot web 应用程序,运行在端口 28081 上,httpd 配置为这样的代理:
ProxyPass / http://localhost:28081/
ProxyPassReverse / http://localhost:28081/
Run Code Online (Sandbox Code Playgroud)
然后在 jsp 页面中,我需要将完整的请求 URL 传递给 Silverlight 小部件;但是
${pageContext.request.serverName}:${pageContext.request.serverPort}
Run Code Online (Sandbox Code Playgroud)
将解决http://localhost:28081。
所以我想依靠X-Forwarded-Host,但有些情况下它确实包含多个代理地址,用逗号分隔。我不确定相信地址的顺序将被保留是否安全。
有没有更好的方法来做到这一点,是在 jsp 中,在 httpd 配置中还是在控制器代码中?
我正在创建一个spring-boot应用程序,我希望能够将一个hashmap的全部内容作为json字符串返回.我怎么做?
我的hashmap如下所示:
private static final Map<String,Animal> animalMap= new HashMap<String,Animal>();
Run Code Online (Sandbox Code Playgroud)
功能
@RequestMapping(value="/animals", method=RequestMethod.GET)
public String showAllAnimals() {
// In here I want to return the content of my hashmap as a Json String
}
Run Code Online (Sandbox Code Playgroud)