当我使用sbt运行一个spark作业时我遇到了问题,我已经完成编译,但是当我运行命令时run
,我遇到了下面的问题
[error] (run-main-0) java.lang.NoSuchMethodError: scala.collection.immutable.HashSet$.empty()Lscala/collection/immutable/HashSet;
java.lang.NoSuchMethodError: scala.collection.immutable.HashSet$.empty()Lscala/collection/immutable/HashSet;
at akka.actor.ActorCell$.<init>(ActorCell.scala:305)
at akka.actor.ActorCell$.<clinit>(ActorCell.scala)
at akka.actor.RootActorPath.$div(ActorPath.scala:152)
at akka.actor.LocalActorRefProvider.<init>(ActorRefProvider.scala:465)
at akka.remote.RemoteActorRefProvider.<init>(RemoteActorRefProvider.scala:124)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at akka.actor.ReflectiveDynamicAccess$$anonfun$createInstanceFor$2.apply(DynamicAccess.scala:78)
at scala.util.Try$.apply(Try.scala:191)
Run Code Online (Sandbox Code Playgroud)
谁知道我该怎么办?
是否可以在用@Autowired
Java编写的Spring配置中使用Spring的注释?
例如:
@Configuration
public class SpringConfiguration{
@Autowired
DataSource datasource;
@Bean
public DataSource dataSource(){
return new dataSource();
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
显然,DataSource接口不能直接实例化,但我在这里直接实例化它是为了简化.目前,当我尝试上述操作时,数据源对象保持为null并且不由Spring自动装配.
我通过返回一个@Autowired
Hibernate SessionFactory
对象成功地工作了FactoryBean<SessionFactory>
.
所以我的具体问题是:有没有办法做到这一点DataSource
?或者更一般地说,在Spring Java配置中自动装配bean的方法是什么?
我应该注意到我使用的是Spring 3.2版.
如何获得两个数字之间的随机数,比如20到30?
我试过了:
val r = new scala.util.Random
r.nextInt(30)
Run Code Online (Sandbox Code Playgroud)
这只允许上限值,但值始终从0开始.有没有办法设置下限值(在示例中为20)?
谢谢!
我需要向API发送一个get请求,但是尽管已经放置了管理员注释获取错误 @WithMockUser(roles="ADMINISTRADOR")
.
我如何发送请求?
API
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@PostAuthorize("returnObject.instancia == principal.instancia.instancia")
public Validacao retrieve(@PathVariable("id") String id) {
return validacaoService.retrieve(id);
}
Run Code Online (Sandbox Code Playgroud)
测试
@Test
@WithMockUser(roles = "ADMINISTRADOR")
public void testCRetrieve() throws Exception {
this.mockMvc
.perform(get("/api/validacao/" + id).with(user("daniela.morais@sofist.com.br")))
.andExpect(status().isOk())
.andReturn();
}
Run Code Online (Sandbox Code Playgroud)
日志
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext
Run Code Online (Sandbox Code Playgroud)
测试类
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ValidacaoAPITest.TestConfiguration.class, WithSecurityConfig.class})
@WebAppConfiguration
public class ValidacaoAPITest {
@EnableWebMvc
@Configuration
public static class TestConfiguration {
Fongo …
Run Code Online (Sandbox Code Playgroud) 我使用创建令牌http://localhost:8080/auth/realms/{realm_name}/protocol/openid-connect/token endpoint
。
grant_type=client_credentials
客户端 ID: ------------
客户端秘密:78296d38-cc82-4010-a817-65c283484e51
现在我想获得领域的用户。然后我http://localhost:8080/auth/admin/realms/{realm_name}/users?username=demo
使用令牌向端点发送请求。但我得到了403 forbidden
回应"error": "unknown_error"
。怎么解决呢?
最近我们搬到了Spring 3.0控制器处理,如下所示:
@Controller
public class MyController {
@RequestMapping(method = RequestMethod.POST)
protected String onSubmit ( Form form, Errors errors) {
// handle POST
}
@RequestMapping(method = RequestMethod.GET)
protected void getForm ( Form form ) {
// handle GET
}
}
Run Code Online (Sandbox Code Playgroud)
现在,由于HEAD请求,我们在日志中获得了大量异常.
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'HEAD' not supported
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:621)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:422)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
...
Run Code Online (Sandbox Code Playgroud)
我想以与GET请求相同的方式支持HEAD请求,但当然遵守HTTP引用:
HEAD方法与GET相同,只是服务器不能
在响应中返回消息体.响应HEAD请求的HTTP头中包含的元信息应该与响应GET请求时发送的信息相同.该方法可用于获得关于请求所暗示的实体的元信息,而无需转移实体主体本身.此方法通常用于测试超文本链接的有效性,可访问性和最近的修改. http://www.ietf.org/rfc/rfc2616.txt
有没有人有一个优雅的解决方案或甚至有一个开箱即用的弹簧解决方案?
我在网上搜索但没有找到任何答案.
我已经阅读了关于scala.math.Integral的问题的答案但是我不明白当作为隐式参数传递时会发生什么.(我想我一般都理解隐式参数概念).Integral[T]
让我们考虑一下这个功能
import scala.math._
def foo[T](t: T)(implicit integral: Integral[T]) { println(integral) }
Run Code Online (Sandbox Code Playgroud)
现在我打电话给foo
REPL:
scala> foo(0)
scala.math.Numeric$IntIsIntegral$@581ea2
scala> foo(0L)
scala.math.Numeric$LongIsIntegral$@17fe89
Run Code Online (Sandbox Code Playgroud)
怎样的integral
争论变得scala.math.Numeric$IntIsIntegral
和scala.math.Numeric$LongIsIntegral
?
目前我尝试使用Kotlin重写我的Java Spring Boot应用程序.我遇到了一个问题,在我的所有使用@Service
依赖注入注释的类中都没有正常工作(所有实例都是null
).这是一个例子:
@Service
@Transactional
open class UserServiceController @Autowired constructor(val dsl: DSLContext, val teamService: TeamService) {
//dsl and teamService are null in all methods
}
Run Code Online (Sandbox Code Playgroud)
在Java中做同样的工作没有任何问题:
@Service
@Transactional
public class UserServiceController
{
private DSLContext dsl;
private TeamService teamService;
@Autowired
public UserServiceController(DSLContext dsl,
TeamService teamService)
{
this.dsl = dsl;
this.teamService = teamService;
}
Run Code Online (Sandbox Code Playgroud)
如果我用@Component
Kotlin 注释组件一切正常:
@Component
open class UserServiceController @Autowired constructor(val dsl: DSLContext, val teamService: TeamService) {
//dsl and teamService are injected properly
}
Run Code Online (Sandbox Code Playgroud)
谷歌为Kotlin提供了许多不同的方法, …
java ×3
scala ×3
spring ×3
spring-mvc ×3
access-token ×1
apache-spark ×1
controller ×1
http ×1
httprequest ×1
implicit ×1
keycloak ×1
kotlin ×1
random ×1
rest ×1
sbt ×1
spring-boot ×1
uml ×1