小编gob*_*ift的帖子

在Webservice中添加AspectJ

我有一个Java EE Web服务(REST),现在想使用AspectJ来创建一个规则,打印出每个传入的服务调用及其参数.

我刚刚阅读了本 教程并实现了以下代码:

的pom.xml

        <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.8.10</version>
    </dependency>

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.10</version>
    </dependency>

</dependencies>
<build>
  <plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.7</version>
        <configuration>
            <complianceLevel>1.8</complianceLevel>
            <source>1.8</source>
            <target>1.8</target>
            <showWeaveInfo>true</showWeaveInfo>
            <verbose>true</verbose>
            <Xlint>ignore</Xlint>
            <encoding>UTF-8 </encoding>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <!-- use this goal to weave all your main classes -->
                    <goal>compile</goal>
                    <!-- use this goal to weave all your test classes -->
                    <goal>test-compile</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)

...并创建了一个Test.aj文件,带有一个Pointcut,它应该在调用getSignOfLife()后打印出一个teststring:

import de.jack.businesspartner.service.BusinessPartnerServiceImpl;
public aspect TestAspectJ {

    pointcut getSignOfLife() : 
      call(void BusinessPartnerServiceImpl.getSignOfLife());

    before() : …
Run Code Online (Sandbox Code Playgroud)

java web-services aspectj maven

13
推荐指数
2
解决办法
316
查看次数

JAXB - 为什么我只能编组到流/文件?

i\xc2\xb4m 目前正在开发一个项目,其架构如下:

\n\n

项目A(应将文件存储到文件夹中。应采用字节[]和名称,并将数据写入文件中。仅此而已,只是一个愚蠢的文件编写器应用程序)

\n\n

项目 B(应从数据库读取数据,生成其 xml 文件并将其作为 byte[] 发送到项目 A,项目 A 将其写入文件系统)

\n\n

现在我的问题是:在项目 B 中,我想生成 xml 文件作为对象,但是 Jaxb-Marshaller 的 API 只提供 marshal() 方法,该方法采用 Writer/File/OutputStream 作为参数...并且我don\xc2\xb4t 想要在项目 B 中提供文件或 OutputStream - 这应该是项目 A 的任务...

\n\n

那么为什么没有方法将生成的 XML 作为 Object 或 byte[] 或其他形式返回呢?

\n

java xml jaxb

3
推荐指数
1
解决办法
2418
查看次数

Wildfly 10:org.dom4j.DocumentFactory 不能转换为 org.dom4j.DocumentFactory

我刚刚在wildfly 10中浪费了最后几天的奇怪随机异常行为......我已经将我的Java 7 EE .war部署到了wildfly,但突然我遇到了这个异常并且部署失败:

java.lang.ClassCastException: org.dom4j.DocumentFactory 不能转换为 org.dom4j.DocumentFactory

java wildfly-10

2
推荐指数
1
解决办法
3297
查看次数

标签 统计

java ×3

aspectj ×1

jaxb ×1

maven ×1

web-services ×1

wildfly-10 ×1

xml ×1