我将JDK版本从8切换到9,由于缺少tools.jar,AspectJ插件不再有效:
目标org.codehaus.mojo的执行默认值:aspectj-maven-plugin:1.10:编译失败:插件org.codehaus.mojo:aspectj-maven-plugin:1.10或其中一个依赖项无法解析:找不到工件com .sun:tools:jar:9.0.1在指定路径C:\ Program Files\Java\jdk-9.0.1 /../ lib/tools.jar
我知道从Java 9 JDK中删除了tools.jar(和rt.jar).我想知道是否有办法让Maven AspectJ插件在没有tools.jar的情况下使用Java 9?
这是我的插件定义版本信息:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<complianceLevel>1.9</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<XnoInline>true</XnoInline>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.0.RC2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.0.RC2</version>
</dependency>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Spring Data REST进行弹性搜索.用于POST的内置REST控制器似乎不起作用:我在尝试发布文档时收到错误.这个问题很容易重现:我创建了一个简单的实体:
@Document(indexName = "user", type = "user", shards = 1, replicas = 0, refreshInterval = "-1")
public class Customer {
@Id
private String id;
@Field(type = FieldType.String, store = true)
private String firstName;
@Field(type = FieldType.String, store = true)
private String lastName;
// getters and setters are skipped
}
Run Code Online (Sandbox Code Playgroud)
库:
public interface UserRepository extends ElasticsearchRepository<User, String> {
}
Run Code Online (Sandbox Code Playgroud)
当我尝试获取所有用户时,我收到了响应:
curl -X GET "http://localhost:9000/users"
{
"_links" : {
"self" : {
"href" : "http://localhost:9000/users{?page,size,sort}",
"templated" : true
},
"search" …Run Code Online (Sandbox Code Playgroud) elasticsearch spring-data spring-data-rest spring-data-elasticsearch
我想知道是否可以将 HTTP 方法添加到使用 Spring HATEOAS 创建的链接中。我希望链接看起来像:
{
"href":http://localhost:8080/admin/users",
"rel": "add",
"method": "POST"
}
{
"href":http://localhost:8080/admin/users/john",
"rel": "remove",
"method": "DELETE"
}
Run Code Online (Sandbox Code Playgroud)
我找不到任何可以让我向链接添加“方法”的内容。
我正在尝试创建一个Spring Cloud配置服务器,它从属性文件而不是github读取配置数据.服务器启动,但不提供文件中的属性.我在classpapath上有两个配置文件:
bootstrap.yml
spring:
application:
name: config-server
Run Code Online (Sandbox Code Playgroud)
config-server.properties
foo=bar
Run Code Online (Sandbox Code Playgroud)
当我去url,据说应该给我foo属性的值:
curl http://localhost:8888/admin/env/foo
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:"timestamp":1415298615005,"status":404,"error":"Not Found","exception":"org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint $ NoSuchPropertyException","message ":"没有这样的属性:foo","path":"/ admin/env/foo"}
我想知道我做错了什么?据我所知,属性文件名应与服务器名称匹配,以便服务器识别.
添加原生配置文件作为spencergibb建议没有帮助.我的application.properties看起来像:
server.port=8888
spring.profiles.active=native
spring.config.name=configserver
spring.application.name=configserver
Run Code Online (Sandbox Code Playgroud)
注意,我必须指定服务器端口.根据Spring Cloud Config Server文档,配置服务器默认在端口8888上启动.在我的情况下,除非我在配置中指定端口,否则服务器从8080开始.
POM文件没有父级和单个依赖项:
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>1.0.0.M2</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
该应用程序没有什么特别之处:
@Configuration
@ComponentScan
@EnableAutoConfiguration
@EnableConfigServer
public class ConfigurationApp {
public static void main(String[] args) {
SpringApplication.run(ConfigurationApp.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
configserver.properties文件包含一个条目:foo = bar
首先,我总是遇到启动错误
2014-11-07 09:35:42.852 ERROR 6972 --- [ main] b.c.PropertySourceBootstrapConfiguration : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/configserver/default/master":Connection refused: …Run Code Online (Sandbox Code Playgroud) 我在为Spring MVC REST资源强制使用SSL时遇到问题.我不需要身份验证,因为它是通过HTTP头中传递的安全令牌处理的,我只需要禁止使用http.由于我已经在项目的其他部分使用Spring安全性,我宁愿继续使用它而不是在Web服务器中配置SSL.当我尝试连接到资源时,我收到" 错误:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议 ",我认为这意味着服务器正在尝试不通过SSL进行响应.
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Mongoose Rest Server</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/application-security.xml
</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>mongoose</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mongoose</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<security:http auto-config="true" use-expressions="true">
<security:intercept-url pattern="/**" requires-channel="https" />
</security:http>
<security:authentication-manager>
</security:authentication-manager>
</beans>
Run Code Online (Sandbox Code Playgroud)
@Controller
@RequestMapping("/mongoose")
public class HarmonyRestController {
private final …Run Code Online (Sandbox Code Playgroud) 我试图模拟一个方法,该方法采用地图并将其他参数作为参数耦合.我的目标是匹配地图条目.最初我将我的模拟定义为:
when(discoveryJobCatalogResourceAccessor.findResource(argThat(allOf(hasEntry("start", "testStart"), hasEntry("level", "testLevel"))), any(Integer.class),
any(Integer.class), any(String.class), any(String.class))).thenReturn(searchResponse);
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
"The method findResource(Map<String,String>, Integer, Integer, String, String) is ambiguous for the type DiscoveryJobCatalogResourceAccessor"
Run Code Online (Sandbox Code Playgroud)
当我更换argThat使用any(HashMap.class)这样的:
when(discoveryJobCatalogResourceAccessor.findResource(any(HashMap.class), any(Integer.class),
any(Integer.class), any(String.class), any(String.class))).thenReturn(searchResponse);
Run Code Online (Sandbox Code Playgroud)
错误消失了,但在这种情况下我无法匹配地图值.似乎Mockito的argThat导致模棱两可.我想知道是否有办法使用而argThat不会导致错误?
java ×4
spring ×2
hamcrest ×1
jetty ×1
junit ×1
maven ×1
maven-plugin ×1
mockito ×1
spring-cloud ×1
spring-data ×1
spring-mvc ×1
ssl ×1
unit-testing ×1