小编Jes*_*sse的帖子

使用带有eclipse和m2e的maven-jaxb-plugin时,ErrorListener丢失

我已经为插件设置了一个项目" org.jvnet.jaxb2.maven2:maven-jaxb2-plugin".它可以工作,但我不喜欢Eclipse编辑器中为"pom.xml"显示的错误消息.消息指出:

Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed: A required class was missing while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate: com/sun/xml/bind/api/ErrorListener
Run Code Online (Sandbox Code Playgroud)

pom和整个项目被标记为错误.

这是我的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>de.gombers.lernen.jaxb</groupId>
    <artifactId>PlayWithJAXB</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
                <configuration>
                    <show>private</show>
                    <nohelp>true</nohelp>
                </configuration>
            </plugin>


            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <extension>true</extension>
                    <useDependenciesAsEpisodes>true</useDependenciesAsEpisodes>
                    <outputDirectory>target/generated-sources/jaxb</outputDirectory>
                    <packageName>de.gombers.lernen.jaxb.generated</packageName>
                    <schemaDirectory>src/main/resources</schemaDirectory>
                    <schemaFiles>Employee.xsd</schemaFiles>
                </configuration>
            </plugin>

        </plugins>


    </build>

    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency> …
Run Code Online (Sandbox Code Playgroud)

java eclipse jaxb maven spring-boot

15
推荐指数
3
解决办法
2万
查看次数

如何在.yml文件中使用Property占位符

我正在使用Java和spring boot.我想知道如何将Property占位符添加到.yml文件中.我发现了一些清晰的例子,但我不确定Property占位符在哪里被实例化.它是在系统env变量,文件等中吗?

Bootstrap.yml

spring:
  cloud:
    config:
      username: ${my.stored.files.username}
      password: ${my.stored.files.password}
      label: ${spring.cloud.find.label}
      uri: ${spring.cloud.config.uri}
      enabled: false
      failFast: true
Run Code Online (Sandbox Code Playgroud)

用户正在使用Property占位符,但是用户在哪里声明了它?这个.yml从哪里读取值?(与上述相同的问题)是否有解释连接的文件?

此Web应用程序将使用"cf push"推送到云代工厂,它将自动选择要配置的manifest.yml文件.如果可能的话,云代工厂的例子会很棒.

理解

app.name=MyApp
app.description=${app.name} is a Spring Boot application
Run Code Online (Sandbox Code Playgroud)

用户可以使用$ {app.name},因为它已定义.我对上面的例子很困惑.用户如何以及在哪里获得"$ {my.stored.files.username}.在哪里定义?我假设它将在system.properties或环境变量中.任何人都可以确认吗?

java yaml manifest string-interpolation spring-boot

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

如何使用 Mono 返回类型对方法进行 junit 测试

抑制单声道并获得身体反应的正确方法是什么?我期望“仅单个项目”出现在 MockHttpServletResponse 的正文响应中。但我看到它是在异步中返回的。

示例方法:

public Mono<String> getData(final String data) {
    return this.webClient.get().uri("/dataValue/" + data)
        .retrieve()
        .bodyToMono(String.class);
}
Run Code Online (Sandbox Code Playgroud)

样本联合体:

@WebMvcTest(DataController.class)
public class DataMockTest {

  @Autowired
  private MockMvc mockMvc;

  @MockBean
  private Service service;

@Test
public void getDataTest() throws Exception {

Mono<String> strMono = Mono.just("Single Item Only");

when(service.getData("DATA")).thenReturn(strMono);

this.mockMvc.perform(get("/some/rest/toget/data")
    .contentType(MediaType.APPLICATION_JSON)
    .accept(MediaType.APPLICATION_JSON))
    .andDo(print())
    .andExpect(status()
        .isOk());
}
Run Code Online (Sandbox Code Playgroud)

测试响应:

MockHttpServletRequest:
      HTTP Method = GET
      Request URI = /some/rest/toget/data
       Parameters = {}
          Headers = [Content-Type:"application/json;charset=UTF-8", Accept:"application/json"]
             Body = null
    Session Attrs = {}

Async:
    Async started = …
Run Code Online (Sandbox Code Playgroud)

mono spring-mvc spring-test spring-boot mockmvc

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

如何使用th:block and th:包含在thymeleaf中?

视觉

我的html其他页面位于编辑文件夹中.

我目前正在使用以下脚本

<!--/*/ <th:block th:include="fragments/header :: header"></th:block> /*/-->
Run Code Online (Sandbox Code Playgroud)

如果html文档位于同一目录中,则上述脚本有效.(例如; index.html能够读取片段).但我创建了一个新目录(名为:edit)来存储我的html页面.我需要退出当前文件夹,以便能够使用../找到片段文件夹

<!--/*/ <th:block th:include="../fragments/header :: header"></th:block> /*/-->
Run Code Online (Sandbox Code Playgroud)

但是这种方法不起作用.如何使用此语法退出文件夹?

thymeleaf spring-boot

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

如何对嵌套数组使用 react-hook-form

我正在尝试使用 react 钩子形式来创建嵌套数组。我在我的示例代码中附加了一个沙箱

代码片段

<ul>
        {fields.map((item, index) => {
          return (
            <li key={item.id}>
              <label> single input </label>
              <input
                name={`test[${index}].task`}
                ref={register()}
                defaultValue={item.task}
              />
              <br />
              <label> first Name </label>
              <input
                name={`test[${index}].name.first`}
                ref={register()}
                defaultValue={item.name.first}
              />
              <br />
              <label>last Name </label>
              <input
                name={`test[${index}].name.last`}
                ref={register()}
                defaultValue={item.name.last}
              />
              <br />

              <label>First Nested </label>
              <input
                name={`test[${index}].nestedArray[${index}].firstNested`}
                ref={register()}
                // defaultValue={item.nestedArray.nested}
              />

              <br />
              <label> Second Nested </label>
              <input
                name={`test[${index}].nestedArray[${index}].secondNested`}
                ref={register()}
                // defaultValue={item.nestedArray.nested}
              />
              <br />

              <button type="button" onClick={() => remove(index)}>
                Delete
              </button>
            </li>
          );
        })}
      </ul>
Run Code Online (Sandbox Code Playgroud)

问题 …

reactjs react-hook-form

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

如何在使用百里香的div中使用if语句?

如果我从下面的源代码中删除div标签,则我的应用程序运行不会出错。但是它显示一个空单元格(正确)。如果单元格为空,我只想隐藏它。

胸腺html

<div th:object="${AppPortModel.Status}" th:if="${AppPortModel.Status} == 'CRITICAL'">  
<h3>
MONITORING
</h3>

<table id ="apCritTable">
    <thead>
    <tr>
        <th> Status </th>
        <th> HostName </th>
        <th> Port Name</th>
        <th> Port Listening Count </th>
    </tr>
    </thead>
    <tbody>
    <tr th:each="AppPortModel, iterStat : ${showap}" th:if="${AppPortModel.Status == 'CRITICAL'}">
        <td th:text ="${AppPortModel.Status}"></td>
         <td th:text="${AppPortModel.host}">${AppPortModel.host}</td>
        <td th:text="${AppPortModel.portOwner}"></td>
         <td th:text="${AppPortModel.count}"></td>
    </tr>
    </tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)

AppPortModel

public class AppPortModel implements Comparable {
private String Status;
private String host;
private String portName;
private String plCount;

//getters and setters

@Override int compareTo(Object o) { …
Run Code Online (Sandbox Code Playgroud)

html thymeleaf

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

如何在 appplicaton.properties 中以 12 因子方式设置系统环境变量?

我无法从我的环境变量中获取值。有很多类似的问题。但是NONE他们的工作对我来说

应用程序属性

spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://localhost:5432/mydb
spring.datasource.username=${SPRING_DATASOURCE_USERNAME}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}
Run Code Online (Sandbox Code Playgroud)

系统变量

Variable name : SPRING_DATASOURCE_USERNAME
Variable Value : dbuser

Variable name : SPRING_DATASOURCE_PASSWORD
Variable Value : 123456789
Run Code Online (Sandbox Code Playgroud)

错误

invalid username/password; logon denied
Run Code Online (Sandbox Code Playgroud)

但是当我对其进行硬编码时,它工作正常。

更新

environment-variables properties-file spring-boot

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

Angular 7+ 如何防止查询参数特殊字符转换为十六进制代码?

示例端点:

https://localhost:4200/test/index.html?param1=username%2passw0rd&baseApi=https://someOtherService/APIBase.jsp?INT/
Run Code Online (Sandbox Code Playgroud)

当我点击上面的端点时。我的网址被转换成这个...

https://localhost:4200/test/index.html?param1=username%2passw0rd&baseApi=https:%2F%2FsomeOtherService%2FAPIBase.jsp
Run Code Online (Sandbox Code Playgroud)

正如您在 baseApi 参数中所看到的,“/”被转换为“%2F”并且值“?INT/”也被删除了。

如何防止 URL 转换“/”并为第二个参数“baseApi”中的值保留“?INT/”值。

参考

angular

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

如何在另一个类中使用值注释?

我如何在这里获得自己的价值并将其用于其他课程?我想创建一个处理所有@Value批注的类,然后其他类可以从此类中获取这些值。一旦我学会了如何从另一个班级获得价值,我将从一个主要班级转变为一个新班级

我如何获得这些变量

@Configuration
@ComponentScan
@EnableAutoConfiguration
public  class WebProperties {

       @Value("${Application}")
        private String app;      
        @Value("${APP_MEMORY_GREP_FOLDERS_APP}")
        private String appFolder;        
        @Value("${APP_MEMORY_GREP_FOLDERS_OPT}")
        private String optFolder;
      //getters and setters
}}
Run Code Online (Sandbox Code Playgroud)

打印到主班

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application {

    @Value("${Application}")
    private String app;

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @PostConstruct
    public void postConstruct() {
        System.out.print("SampleApplication started: " + app);
    }
}
Run Code Online (Sandbox Code Playgroud)

不必再次调用@Value

java spring-boot

0
推荐指数
1
解决办法
982
查看次数