当我尝试测试我的maven插件时,我收到以下错误:
WARNING: Error injecting: org.apache.maven.repository.legacy.LegacyRepositorySystem
com.google.inject.ProvisionException: Guice provision errors:
1) Error injecting: org.apache.maven.artifact.resolver.DefaultArtifactResolver
at ClassRealm[plexus.core, parent: null]
at ClassRealm[plexus.core, parent: null]
while locating org.apache.maven.artifact.resolver.ArtifactResolver
while locating org.apache.maven.repository.legacy.LegacyRepositorySystem
1 error
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:977)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1003)
at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:47)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1021)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:59)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:968)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1014)
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:964)
at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:79)
at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:53)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:243)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:235)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:229)
at org.codehaus.plexus.PlexusTestCase.lookup(PlexusTestCase.java:206)
at org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:118)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at …Run Code Online (Sandbox Code Playgroud) 我在一台主机上使用两个 docker 容器。第一个基于带有一些转发端口(7474)的普通 neo4j:2.3 镜像。第二个是基于 python:2.7 的容器。使用 curl 我可以从主机级别和第二台机器(使用主机本身的 IP)访问 db。问题是我编写并移植到该容器的代码将不再运行。我收到这样的错误:
Traceback (most recent call last):
File "/app/runserver.py", line 1, in <module>
from orangebox import app
File "/app/orangebox/__init__.py", line 5, in <module>
from orangebox.context import ob
File "/app/orangebox/context.py", line 2, in <module>
from orangebox.domain.factory import DomainFactory
File "/app/orangebox/domain/factory.py", line 4, in <module>
from orangebox.domain.boxes import Box
File "/app/orangebox/domain/boxes.py", line 3, in <module>
from orangebox.domain.users import User
File "/app/orangebox/domain/users.py", line 4, in <module>
class User(StructuredNode):
File "/app/src/neomodel/neomodel/core.py", line 65, in __new__ …Run Code Online (Sandbox Code Playgroud) 我正在使用Intellij和WebSphere 8.当我在IDE中运行时,服务器正常工作.当我尝试在调试模式下运行它时,它失败并出现以下错误:
C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin\generated_websphere_server_start_script.cmd
C:\IBM\WebSphere\AppServer\java\bin\java -Dfile.encoding=windows-1252 -classpath "C:\IBM\WebSphere\AppServer\runtimes\com.ibm.ws.admin.client_8.5.0.jar;C:\IBM\WebSphere\AppServer\plugins\com.ibm.ws.security.crypto.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.3\plugins\webSphereIntegration\lib\webSphereIntegration.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.3\plugins\JavaEE\lib\javaee-impl.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.3\lib\openapi.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.3\plugins\webSphereIntegration\lib\specifics\webSphereClientImpl.jar" com.intellij.javaee.oss.process.JavaeeProcess 62847 com.intellij.j2ee.webSphere.agent.WebSphereAgent
Error: JDWP agent already loaded - please check java command line options
[2014-08-11 01:58:59,248] Artifact x.ear: Server is not connected. Deploy is not available.
JVMJ9TI064E Agent initialization function Agent_OnLoad failed for library jdwp, return code -1
Detected server admin port: 8880
JVMJ9VM015W Initialization error for library j9jvmti26(-3): JVMJ9VM009E J9VMDllMain failed
Detected server http port: …Run Code Online (Sandbox Code Playgroud) 我正在运行最新的(此时)pycharm版本,其中最新的docker插件可用于该版本(2.1.2,2.2不工作,2.3不支持).
问题是我得到了
Couldn't refresh skeletons for remote interpreter
{"message":"starting container with HostConfig was deprecated since v1.10 and removed in v1.12"}
Run Code Online (Sandbox Code Playgroud)
尝试设置远程解释器时出错(然后进入"无效"状态).我的docker版本是1.11(也用于1.12-rc).我认为它可能会在1.9.0上工作,但这使我无法使用docker的新功能,这是令人惊讶的,因为1.11版本已存在很长一段时间......任何人都有相同的问题?有没有解决的办法?我的意思是拥有更新的docker并使其与最新的pycharm一起使用.
我正在研究 Gradle-Kotlin-Hibernate 项目。我想保持我的一些类不可变,这在 Kotlin 中特别容易。这对于@Entity来说效果很好
@Entity(name = "SOMETHING")
class MeetingKeychain(
val immutableProp: String
) {
// ID and others
}
Run Code Online (Sandbox Code Playgroud)
感谢kotlin-jpa插件的使用。但相同的插件不适用于@Embeddable。
@Embeddable
class MeetingKeychain(
val immutableProp: String
) {
// ID and others
}
Run Code Online (Sandbox Code Playgroud)
抛出以下异常:
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.component.PojoComponentTuplizer]
at org.hibernate.tuple.component.ComponentTuplizerFactory.constructTuplizer(ComponentTuplizerFactory.java:98)
at org.hibernate.tuple.component.ComponentTuplizerFactory.constructDefaultTuplizer(ComponentTuplizerFactory.java:119)
at org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:64)
at org.hibernate.mapping.Component.getType(Component.java:169)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:398)
at org.hibernate.mapping.Property.isValid(Property.java:225)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:595)
at org.hibernate.mapping.RootClass.validate(RootClass.java:265)
at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:443)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)
... 46 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) …Run Code Online (Sandbox Code Playgroud) 我正试图用Mockito实现这种行为:
当类型O的对象应用于方法M时,mock应该对类型为O的对象执行另一个方法,将其自身作为参数传递.
毕竟有可能吗?
有一个用 Java 和 Kotlin 编写的应用程序。我在调试模式下运行它。调试器被正确连接。如果我的断点是在 Java 代码中设置的,它就会被命中,但 Kotlin 代码中的任何断点都不会。这是为什么?如何让它在 IntelliJ 中工作?
两种类型的源都位于 src/main 中。
实际上在 StackOverflow 上有这个问题的答案。这可能被标记为Intellij IDEA 调试器的副本,不适用于 Gradle Vert.X 项目
我想要一些资源但是如果遗失了就忽略了其他资源......如何做到这一点?我认为我只能这样做
<context:property-placeholder
ignore-resource-not-found="true"
location="required.properties, not-required-override.properties" />
Run Code Online (Sandbox Code Playgroud)
这会影响那里列出的每个配置.
//编辑这是一个有效的例子
<bean id="requiredProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:database.properties</value>
<value>classpath:storage.properties</value>
<value>classpath:log4j.properties</value>
<value>classpath:mailing.properties</value>
</list>
</property>
</bean>
<context:property-placeholder
properties-ref="requiredProperties" ignore-resource-not-found="true"
location="file:\${user.dir}/config/cvnizer.properties" />
Run Code Online (Sandbox Code Playgroud) 我正在通过Gradle使用JUnit 5平台.
我当前的构建文件有配置子句
junitPlatform {
platformVersion '1.0.0-M5'
logManager 'java.util.logging.LogManager'
enableStandardTestTask true
filters {
tags {
exclude 'integration-test'
}
packages {
include 'com.scherule.calendaring'
}
}
}
Run Code Online (Sandbox Code Playgroud)
这很好.但我还需要运行集成测试,这些测试需要构建,docker化并在后台运行应用程序.所以我应该有这样的第二个配置,然后才会启动......如何实现这个目标?通常我会扩展测试任务创建IntegrationTest任务,但它不适合JUnit平台,其中没有简单的任务运行测试...
我知道我可以这样做
task integrationTests(dependsOn: "startMyAppContainer") {
doLast {
def request = LauncherDiscoveryRequestBuilder.request()
.selectors(selectPackage("com.scherule.calendaring"))
.filters(includeClassNamePatterns(".*IntegrationTest"))
.build()
def launcher = LauncherFactory.create()
def listener = new SummaryGeneratingListener()
launcher.registerTestExecutionListeners(listener)
launcher.execute(request)
}
finalizedBy(stopMyAppContainer)
}
Run Code Online (Sandbox Code Playgroud)
但有更简单的方法吗?更一致.
我试图用很少的努力实现完全有效的持久性无知.我有很多问题:
最简单的选择
它真的很简单 - 是否可以像在SOA中那样使用Spring Data注释注释实体(但是让它们真正做到逻辑)?除了必须在实体中使用持久性注释之外还有什么后果,这实际上并不遵循PI原则?我的意思是Spring Data的情况确实如此 - 它提供了很好的存储库,可以完成DDD中的存储库应该做的事情.问题在于实体本身呢......
更难的选择
为了使实体不知道它所操作的数据来自何处,通过构造函数将该数据作为接口注入是很自然的.另一个优点是我们总是可以执行延迟加载 - 例如我们默认在Neo4j图数据库中.缺点是Aggregates(由Entities组成)将完全了解所有数据,即使他们不使用它们 - 可能会导致调试困难,因为数据完全暴露(DAO将像Aggregates一样分层).这也会迫使我们为存储库使用一些适配器,因为它们不再存储真实的实体......并且任何翻译都是丑陋的...另一件事是我们不能在没有这样的DAO的情况下实例化实体 - 尽管可能存在 - 域中的内存实现......再次,更多层.有人说注入DAO确实会破坏PI.
最难的选择
实体可以缠绕在一个懒惰的加载器上,它决定了数据的来源.它既可以是内存中也可以是数据库内,它可以处理任何需要事务的操作等等.虽然复杂的层,但可能在一定程度上是通用的......?在这里阅读一下
你知道其他任何解决方案吗?或者也许我错过了提到的东西.请分享你的想法!
persistence entity domain-driven-design persistence-ignorance
有人可以向我解释以下行为的原因吗?
EntityA首先创建,然后使用em.persist(..)方法持久化。@PrePersistcallback 在事务结束前执行。它工作正常。
在新交易EntityA中使用 em 查询获得。然后,执行一些修改其持久字段的操作,此事务结束。但是在 上em.flush(),该@PreUpdate方法从未被调用,也从未被调用@PrePersist(后者是我预料到的)。为什么?
// 编辑
那是失败前的痕迹。“完成实体化实体”是事务中第一个操作失败的结果。
DEBUG: org.hibernate.engine.internal.TwoPhaseLoad - Done materializing entity [com.example.entity#1]
DEBUG: org.hibernate.event.internal.AbstractFlushingEventListener - Processing flush-time cascades
DEBUG: org.hibernate.ejb.AbstractEntityManagerImpl - Mark transaction for rollback
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Initiating transaction rollback
DEBUG: org.springframework.orm.jpa.JpaTransactionManager - Rolling back JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@341a736]
DEBUG: org.hibernate.engine.transaction.spi.AbstractTransactionImpl - rolling back
DEBUG: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction - rolled JDBC Connection
Run Code Online (Sandbox Code Playgroud)
谢谢!
我在尝试实例化此类时遇到此错误:
public class ActivationAjaxBehavior extends AbstractAjaxBehavior {
private static final long serialVersionUID = 3103844752146887631L;
private final String tokenKey = "token";
@SpringBean
private RegistrationService registrationService;
public ActivationAjaxBehavior() {
super();
//Injector.get().inject(this);
}
@Override
public void onRequest() {
RequestCycle requestCycle = RequestCycle.get();
ServletWebRequest webRequest = (ServletWebRequest) requestCycle
.getRequest();
HttpServletRequest request = webRequest.getContainerRequest();
String extractedToken = (String) request.getParameter(tokenKey);
try {
registrationService.confirmUser(extractedToken);
proceedToSignInPage();
} catch (WrongTokenException e) {
e.printStackTrace();
proceedToSignUpPage();
}
}
private void proceedToSignInPage() {
throw new RestartResponseException(
SignInPage.class);
}
private void proceedToSignUpPage() { …Run Code Online (Sandbox Code Playgroud) 为什么在这里不承认自我符号?我正在使用Scala 2.12.
trait Parsers[ParseError, Parser[+_]] {
def or[A](s1: Parser[A], s2: Parser[A]): Parser[A]
case class ParserOps[A](p: Parser[A]) {
def |[B>:A](p2: Parser[B]): Parser[B] = self.or(p,p2)
def or[B>:A](p2: => Parser[B]): Parser[B] = self.or(p,p2)
}
}
Run Code Online (Sandbox Code Playgroud) java ×6
docker ×2
kotlin ×2
spring ×2
testing ×2
case-class ×1
config ×1
constructor ×1
entity ×1
hibernate ×1
jakarta-ee ×1
jpa ×1
junit ×1
junit5 ×1
maven ×1
methods ×1
mockito ×1
neomodel ×1
persistence ×1
plugins ×1
properties ×1
py2neo ×1
pycharm ×1
python ×1
scala ×1
self ×1
superclass ×1
traits ×1
websphere ×1
wicket ×1