小编May*_*y12的帖子

如何使用jaxb2-maven-plugin在源文件夹中生成java类?

我使用jaxb2-maven-plugin来生成java类.有插件属性:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <id>xjc</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <!-- The package of your generated sources -->
                <packageName>com.bcap.me.JaxB</packageName>
                <sources>
                    <source>src/main/resources/xsds/pos.xsd</source>
                </sources>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

运行mvn clean compile插件后,在target\classes\com\bcap\me\JaxB目录中创建类.但我需要在源文件夹(包)中有类:src\main\java\com\bcap\me\JaxB 如何做到这一点?

更新 我添加outputDirectory属性,但我不确定这种方法的正确性:

<!--<packageName>com.bcap.me.JaxB</packageName>-->
<outputDirectory>src/main/java/com/bcap/me/JaxB</outputDirectory>
Run Code Online (Sandbox Code Playgroud)

UPDATE

我解决了我的情况:

  <execution>
                        <id>xjc_pos</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                        <configuration>
                            <!-- The package of your generated sources -->
                            <packageName>com.bcap.me.JaxB</packageName>
                            <outputDirectory>src/main/java</outputDirectory>
                            <sources>
                                <source>src/main/resources/xsds/pos.xsd</source>
                            </sources>
                            <generateEpisode>false</generateEpisode>
                            <clearOutputDir>false</clearOutputDir>
                        </configuration>
                    </execution>
Run Code Online (Sandbox Code Playgroud)

感谢@ulab

java jaxb jaxb2-maven-plugin

11
推荐指数
1
解决办法
9093
查看次数

如何使用javascript中的参数运行cmd.exe

我正在尝试编写javascript,它应该运行带有指定命令行的cmd.exe,例如docs.google.com/file/d/0B7QHCoQDlEvKWUZSX3oxUDI2SDg/edit:

我在microsoft网站上阅读shellexecute方法后准备一个代码:

var objShell = new ActiveXObject("Shell.Application");
        objShell.ShellExecute("cmd.exe", "C: cd C:\\pr main.exe blablafile.txt auto", "C:\\WINDOWS\\system32", "open", "1");
Run Code Online (Sandbox Code Playgroud)

但它不会在cmd.exe中插入命令行.

有人能帮助我吗?先感谢您.

javascript command-line cmd shellexecute

10
推荐指数
1
解决办法
8万
查看次数

如何使用Java中的jcifs将文件从smb共享复制到本地驱动器?

有人可以帮我将文件从共享文件夹复制到本地驱动器吗?我的代码是:

import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileInputStream;
import jcifs.smb.SmbFileOutputStream;;


public class smb {

      /**
      * @param args
      * @throws IOException
       */
      public static void main(String[] args) throws IOException {
            // TODO Auto-generated method stub


          String urlToBackUpFile = "smb://ip/backup$/test.txt"; 
          System.out.println("smb folder of source file" + urlToBackUpFile);
          NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, "login", "pass");


            SmbFile dir = new SmbFile(urlToBackUpFile, auth);
            System.out.println(dir.getDate());
            SmbFile dest = new SmbFile ("C:/SQLRESTORESTAGE/v2.bak");
            dir.copyTo(dest);
      }
}
Run Code Online (Sandbox Code Playgroud)

不复制文件文件.我收到一条消息"无法连接到服务器",但程序显示源文件的dir.getDate()(以及文件名和长度).所以我认为目标文件夹的问题(C:/ SQLRESTORESTAGE /).另外,我只能阅读源文件.你能帮我修改代码或建议吗?谢谢.

java smb jcifs file-copying

6
推荐指数
2
解决办法
4万
查看次数

SOAPExceptionImpl:无效的内容类型:文本/html。这是错误消息而不是 SOAP 响应吗?

我需要有关调用 Web 服务的帮助。我org.springframework.ws.client用来调用WS,代码如下:

Response response = (Response) getWebServiceTemplate().marshalSendAndReceive(
                "http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import",
                request,
                new SoapActionCallback("http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import"));
Run Code Online (Sandbox Code Playgroud)

此外,我可以http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import使用 SOAP UP调用 WS 并使用此链接(看起来很奇怪)接收响应。它工作正常。

从 IDE 运行代码后,我收到下一个堆栈跟踪:

Exception in thread "main" java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:677)
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:693)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:969)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:958)
    at com.mayacomp.feeder.Application.main(Application.java:33)
Caused by: org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:text/html. Is this an error message instead of a …
Run Code Online (Sandbox Code Playgroud)

java soap spring-ws

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

如何从lambda表达式返回一个值?

我有一个collection(concurrentHashMap)和一个方法,它应该在一个单独的线程中工作并返回numOfApples:

public int getApples(String treeNum) {
    int numOfApples = null;
    Runnable task = () -> {concurrentHashMap.get(treeNum).getApples(); };
    new Thread(task).start() ;
    return numOfApples;
}
Run Code Online (Sandbox Code Playgroud)

是否可以将lambda expression(concurrentHashMap.get(treeNum).getApples())中的num个数量传递给numOfApples变量?

java lambda java-8

6
推荐指数
1
解决办法
4055
查看次数

在JUnit测试中使用Transaction注释时,数据不会保存在DB中

同事们,我无法解决春季交易超过一周的问题.我创建了非常相似的帖子(为什么我使用@Transactional注释时数据未保存?),但无法解决其中的问题; 当然我考虑了给@Florian Schaetz的建议.我请你帮助我.

所以,我有测试类:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = AppConfig.class, loader = AnnotationConfigContextLoader.class)
@Transactional

public class OdValuesServiceTest {
    static final Logger LOG = Logger.getLogger(OdValuesServiceTest.class.getName());

    @Autowired
    OdValuesService odValuesService;
    @Autowired
    DBCommonsService dbCommonsService;

    @Transactional ("txManagerDU")
    @Test
    @Commit

    public void addOdValue() throws Exception {


                OdValuesEntity odValuesEntity = new OdValuesEntity();
                odValuesEntity.setId(dbCommonsService.getNextDocOD("OD_VALUES_ID_GEN"));
                odValuesEntity.setSysname("Name" + DataGenerator.getRandomISIN());
                odValuesEntity.setName("Name");
                odValuesEntity.setIsIn((short) 1);
                odValuesEntity.setvType(2);
                odValuesEntity.setMfu((short) 0);
                odValuesEntity.setIsin("AU000A0JP922");
                odValuesEntity.setCfi("");

                odValuesService.addOdValue(odValuesEntity);
    }
}
Run Code Online (Sandbox Code Playgroud)

接口类addOdValue看起来像:

public interface OdValuesDAO {

    public void addOdValue (OdValuesEntity odValuesEntity);

}
Run Code Online (Sandbox Code Playgroud)

而DAO实现类是:

@Component
public class OdValuesDAOImpl implemets OdValuesDAO …
Run Code Online (Sandbox Code Playgroud)

java junit spring jpa transactions

6
推荐指数
1
解决办法
2270
查看次数

添加日志记录后,为什么 Spring Boot 应用程序无法完全启动?

同事们,这是我的 pom 的一部分:

<dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter</artifactId>
                    <version>1.2.5.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
            <version>1.2.5.RELEASE</version>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

这是我的 \src\main\resources\log4j.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <!-- Appenders -->
    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Target" value="System.out" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-5p: [%d{MMM-dd HH:mm:ss,SSS}] %c{3} - %m%n" />
        </layout>
    </appender>


    <!-- File Appender -->
    <appender name="file" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="C:/LOGS/spring-ws.log"/>
        <param name="MaxFileSize" value="10000KB"/>
        <param name="MaxBackupIndex" value="20"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-5p: [%d{MMM-dd HH:mm:ss,SSS}] %c{3} - %m%n" /> …
Run Code Online (Sandbox Code Playgroud)

java log4j spring-boot

5
推荐指数
1
解决办法
6405
查看次数

在将参数传递给Bean时,没有找到类型[java.lang.String]的限定bean用于依赖项

我正在研究Spring并尝试创建bean并将参数传递给它.Spring配置文件中的bean看起来像:

@Bean
@Scope("prototype")
public InputFile inputFile (String path)
{
    InputFile inputFile = new InputFile();
    inputFile.setPath(path);
    return inputFile;
}
Run Code Online (Sandbox Code Playgroud)

InputFile类是:

public class InputFile {
    String path = null;
    public InputFile(String path) {
        this.path = path;
    }
    public InputFile() {

    }
    public String getPath() {
       return path;
    }
    public void setPath(String path) {
        this.path = path;
    }
}
Run Code Online (Sandbox Code Playgroud)

在主要方法中我有:

InputFile inputFile = (InputFile) ctx.getBean("inputFile", "C:\\");
Run Code Online (Sandbox Code Playgroud)

C:\\ - 是我试图传递的参数.

我运行应用程序并收到root异常:

org.springframework.beans.factory.NoSuchBeanDefinitionException:通过引起[java.lang.String中]找到依赖性否类型的排位豆:预期至少1种豆,其有资格作为自动装配候选这种依赖性.依赖注释:{}

我做错了什么以及如何解决它?

java spring

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

如何修复 javax.xml.ws.WebServiceException: java.lang.NullPointerException?

我正在运行 Spring Boot 应用程序 ( mvn:spring-boot:run) 并获取下一个堆栈跟踪:

 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.2.RELEASE)

2016-02-10 09:57:31.350  INFO 8868 --- [           main] com.comp.config.Application         : Starting Application on SOFT12 with PID 8868 (C:\Users\Maya\git\app-services\target\classes started by Maya in C:\Users\Maya\git\app-services)
2016-02-10 09:57:31.356  INFO 8868 --- [           main] com.comp.config.Application         : No active profile set, falling back to default profiles: default
2016-02-10 …
Run Code Online (Sandbox Code Playgroud)

java web-services cxf spring-boot

5
推荐指数
1
解决办法
1万
查看次数

使用 Spring Data Jpa 中的 CrudRepository 时如何修复 NoSuchBeanDefinitionException?

同事们,我正在尝试使用 Spring Crud Repository 从数据库获取数据:

@Component
public interface AssetsGapSortDAO  extends CrudRepository<AssetsGapSortEntity, Integer> {
   AssetsGapSortEntity getByIsin(String ISIN);
}
Run Code Online (Sandbox Code Playgroud)

JPA 实体如下所示:

@Entity
@Table(name = "Assets", schema = "dbo", catalog = "")
public class AssetsGapSortEntity {
    private BigInteger id;

    private String shortName;
    private String isin;
    private int registrationDate;
    /*Some other properties*/

    @Basic
    @Column(name = "id")
    public BigInteger getId() {
        return id;
    }

    public void setId(BigInteger id) {
        this.id = id;
    }


    @Id
    @Column(name = "ShortName")
    public String getShortName() {
        return shortName;
    }

    public …
Run Code Online (Sandbox Code Playgroud)

java spring hibernate spring-data-jpa

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