我有一个基于代码的mavenized配置Spring 3.2.4 Web应用程序.当我使用Maven/pom.xml构建应用程序时,我得到一个错误,即web.xml丢失.首先,我尝试创建一个空的web.xml.这是项目方面发生变化的时刻(我不知道为什么).它从动态Web模块3.0切换到3.1,这是不可逆转的.如何将其再次更改为Dynamic Web Modules 3.0 ???

另外我无法删除JAX-RS.尝试这样做会导致:
Failed while uninstalling JAX-RS (REST Web Services) 1.0.
org.eclipse.jst.javaee.web.internal.impl.WebAppImpl cannot be cast to org.eclipse.jst.j2ee.webapplication.WebApp
Run Code Online (Sandbox Code Playgroud)
后来我发现我可以通过在pom.xml中插入相应的插件来避免Maven编译错误:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我在pom.xml中定义了三个配置文件:
<profiles>
<profile>
<id>ABC</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<url.base>http://server1.de</url.base>
<url.searchevse>/search</url.searchevse>
<url.reservation>/reservation</url.reservation>
<url.cancelation>/reservation/cancel</url.cancelation>
<xxx.devmode>false</xxx.devmode>
</properties>
</profile>
<profile>
<id>XYZ</id>
<properties>
<url.base>http://server2.de</url.base>
<url.searchevse>/cns/search</url.searchevse>
<url.reservation>/cns/reservation</url.reservation>
<url.cancelation>/cns/cancel_reservation</url.cancelation>
<xxx.devmode>false</xxx.devmode>
</properties>
</profile>
<profile>
<id>DEVELOPMENT</id>
<properties>
<url.base>http://localhost/noservices</url.base>
<url.searchevse>/no/search</url.searchevse>
<url.reservation>/no/reservation</url.reservation>
<url.cancelation>/no/cancel_reservation</url.cancelation>
<xxx.devmode>true</xxx.devmode>
</properties>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
在Eclipse中,我有一个运行配置
清洁安装XYZ
我在Goals字段中使用-PXYZ(和-P XYZ)也尝试了
干净安装
在" 目标"字段中," 配置文件"字段中的XYZ .
问题:
从不使用定义的配置文件.
在Properties - > Maven - > Active Maven Profiles下插入活动配置文件不起作用(或者我必须使用特殊语法,例如逗号后面没有空格).
我们有很多服务使用 Spring Boot 2.0.x 并且io.zipkin.brave.Tracer已经使用并且运行正常。Tracer 用于用 @Component 注解的类中,并且它有一个以 Tracer 作为参数的构造函数。这是一个示例片段:
@Component
public class CrmMessagePublisher {
private static final Logger LOGGER = LoggerFactory.getLogger(CrmMessagePublisher.class);
private static final String EVENT_NAME_HEADER = "service.eventName";
private static final String EXCHANGE_EVENT = "service.event";
private static String applicationName;
private RabbitTemplate rabbitTemplate;
@Autowired
private Tracer tracer;
@Autowired
public CrmMessagePublisher(
RabbitTemplate rabbitTemplate,
@Value("${spring.application.name}") final String applicationName,
Tracer tracer
) {
this.rabbitTemplate = rabbitTemplate;
CrmMessagePublisher.applicationName = applicationName;
this.tracer = tracer;
}
...
Run Code Online (Sandbox Code Playgroud)
现在我想写一个junit测试但我总是得到
Test ignored.
java.lang.IllegalStateException: Failed to load …Run Code Online (Sandbox Code Playgroud) 我正在使用springdoc-maven-openapi-plugin这种方式:
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<apiDocsUrl>http://localhost:9090/v3/api-docs</apiDocsUrl>
<outputDir>${project.build.directory}/my_open_api_specification/</outputDir>
<outputFileName>my_open_api_specification.yml</outputFileName>
<skip>false</skip>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这会在目标文件夹中生成一个 OpenAPI 文档,其名称带有后缀“ .yml ”,但实际上它是一个 JSON。
我如何告诉插件有效地创建 YAML 格式的文档?
我有一个表R,其中包含表P的外键。表P中有一个列,告诉我表P中的记录是什么类型。与 P.type 列中的可能值相关,根据表存在。因此,如果 P.type 为“C”,则表示名为 C 的表,如果值为“D”,则表示名为 D 的表。
现在我想要一个 SELECT 语句,它根据 P.type 分别给出表 C 或 D 中的值。为了使其更复杂,结果中的列的数量/类型应有所不同。
SELECT r.id, r.pid, p.type,
FROM R r
LEFT JOIN P p ON r.pid = p.pid
WHERE r.id = 123 LIMIT 1;
Run Code Online (Sandbox Code Playgroud)
现在我已经得到了P表的记录。根据列类型的值,我想决定要在先前的查询中加入哪个表(C 或 D)。如果我必须连接表 D,则返回的列(结果集)应保持原样,但如果必须连接表 C,则应返回另一列。因此,SELECT 子句从
选择 r.id、r.pid、p.type FROM ...
到
选择 r.id、r.pid、p.type、c.name FROM ...
预编码:
SELECT r.id, r.pid, p.type(, c.name) -- c.name my or may not be in the result depending on the joined table
FROM R r
LEFT JOIN …Run Code Online (Sandbox Code Playgroud) 如何在"LiquiBase"表示法中定义变更集以更新带有AND-ed WHERE子句的表列:
<changeSet id="ddl update tables : modify datatype for MY_TABLE.STATE_ABBREV" author="xxx">
<preConditions onFail="MARK_RAN" onFailMessage="Column MY_TABLE.STATE_ABBREV doesn't exists.">
<and>
<tableExists tableName="MY_TABLE"/>
<columnExists tableName="MY_TABLE" columnName="STATE_ABBREV"/>
</and>
</preConditions>
<update tableName="MY_TABLE">
<column name="STATE_ABBREV" value="AS"/>
<where>AGU /***AND STATE_ID=3***/ ??????????????????
</where>
</update>
</changeSet>
Run Code Online (Sandbox Code Playgroud) 有没有办法以编程方式将构建版本从 Spring Boot 应用程序的 POM 设置为 springdoc-openapi-maven-plugin 生成的 OpenApi YAML?
我怎样才能实现它?
目前我已经通过这种方式集成了 springdoc-openapi-maven-plugin :
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<apiDocsUrl>http://localhost:9090/v3/api-docs.yaml</apiDocsUrl>
<outputFileName>my_open_api_specification.yml</outputFileName>
<outputDir>${project.build.directory}/my_open_api_specification/</outputDir>
<skip>false</skip>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我有一个使用 OpenApi 注释来注释方法的接口:
@Tag(name = "API Operationen")
@RequestMapping
public interface RestApi {
...
@Bean
default OpenAPI myOpenApi() {
return new OpenAPI()
.info(new Info()
.title("The title")
.version("1.0") <-- I want to dynamically set this version with the value coming from BuildProperties (POM version).
.description("The description"));
}
}
Run Code Online (Sandbox Code Playgroud)
我使用 …
在Spring 3.3中,我有一个映射到数据库表的实体.在这个实体类中,我有使用@JsonProperty注释的所有属性,例如@JsonProperty("ID").进入控制器,调用服务以通过使用DAO /存储库来获取此类实体.这很好用但是当我使用@ResponseBody将此实体发送回请求者时,所有属性都会被发送两次.一旦要求,但再一次开始小写直到第一个驼峰案件出现.一个例子...
public class MyEntity {
@JsonProperty("MYSpecialSuperId")
private String MYSpecialSuperId;
...
public String getMYSpecialSsuperId() {
return this.MYSpecialSuperId;
}
}
Run Code Online (Sandbox Code Playgroud)
在JSON字符串化后,结果是:
{ "MYSpecialSuperId":""9", "myspecialSuperId":"9" }
Run Code Online (Sandbox Code Playgroud)
为什么结果中的属性是两次,为什么字体不同?
顺便说一句:我的想法是让Java属性以大写字母开头,即使还有一个以上的大写字母.
MapStruct 1.2是否可以将具有特定值的源属性映射到目标中的特定不同值?
我想这样的事情:
public abstract class JiraKpmMapper {
@Mappings({
@Mapping(source = "mySource.propA", target = "myTarget.propX")
})
@ValueMappings({
@ValueMapping(source = "ABC", target = "XYZ"),
@ValueMapping(source = "123", target = "789")
})
public abstract MyTarget source2Target(final MySource mySource);
}
Run Code Online (Sandbox Code Playgroud)
因此,当MapStruct在映射期间看到当mySource.propA具有值"ABC"时,myTarget.propX需要设置为值"XYZ",依此类推.
更确切地说,我甚至想要一些更详细的东西:目标应该是一个阶级避风港的三个属性,其中必须将得到的目标值分成.例如,如果mySource.propA的值为"ABC",则目标myTarget应该获得类似"V01.123.456.AB"的值.该值又应分为preValue,middleValue和endValue:
preValue ="V01"
middleValue ="123.456"
endValue ="AB"
因此,没有包含完整结果字符串的属性.
这就是为什么我已经编写了一个自定义映射器,并告诉MyMapper通过它来使用它
@Mapper(componentModel = "spring", uses = MyCustomMapper.class)
Run Code Online (Sandbox Code Playgroud)
这个工作到目前为止,但我无法实现它告诉MyCustomMapper将"V01.123.456.AB"放入目标,当souzrce带有"ABC"时.
在哪里可以找到有关可在运行时修改的 Hikari 属性的信息?我尝试修改connectionTimeout。我可以做到这一点,并且它将无一例外地被修改HikariDataSource(通过设置然后获取属性进行检查),但它没有效果。如果我最初这样做:
HikariConfig config = new HikariConfig();
config.setConnectionTimeout(12000);
HikariDataSource pool = new HikariDataSource(config);
Run Code Online (Sandbox Code Playgroud)
后来我就这么做了
config.setConnectionTimeout(5000);
Run Code Online (Sandbox Code Playgroud)
Hikari 尝试获取新连接需要 12 秒,而不是 5 秒。
或者有没有办法改变这个值并产生效果?是否还有其他具有相同行为的属性?
spring-boot ×3
eclipse ×2
json ×2
maven ×2
spring ×2
springdoc-openapi-maven-plugin ×2
brave ×1
changeset ×1
conditional ×1
hikaricp ×1
jackson ×1
java ×1
join ×1
liquibase ×1
mapping ×1
mapstruct ×1
openapi ×1
pom.xml ×1
profile ×1
spring-mvc ×1
sql ×1
where-clause ×1
yaml ×1
zipkin ×1