不确定我做错了什么,但我有一个webapp配置,可以在单元测试中工作,但在生产中死于Component bean.
bean扩展WebServiceGatewaySupport
并扩展了接口.
我这样在java中定义它:
@Component("myShippingImplementation")
public class MyShippingImplemenation extends WebServiceGatewaySupport implements ShippingImplementation {
private String addressValidationUri;
public String getAddressValidationUri() {
return addressValidationUri;
}
public void setAddressValidationUri(String addressValidationUri) {
this.addressValidationUri = addressValidationUri;
}
}
Run Code Online (Sandbox Code Playgroud)
并且XML bean配置是:
<bean id="myShippingImplementation" class="com.cerp.service.shipping.MyShippingImplemenation" autowire="byType">
<property name="addressValidationUri" value="https://www.testurl.com" />
<property name="defaultUri" value="https://www.alturl.com" />
<property name="marshaller" ref="marshaller"/>
<property name="unmarshaller" ref="marshaller"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
如果我在单元测试中连接它,它可以工作:
public class MyServiceClientTest extends BaseWebServiceTest {
@Autowired MyShippingImplemenation c;
Run Code Online (Sandbox Code Playgroud)
(BaseWebServiceTest使用SpringJUnit4ClassRunner)
但如果我在控制器中连接它并使用以下命令将其从Tomcat运行:
@Controller
@RequestMapping(value="/work/settings")
public class SettingsController {
@Autowired
SignupServiceI signupService;
@Autowired
ShippingImplementation myShipImplementation; …
Run Code Online (Sandbox Code Playgroud) 很多时候我在一个返回List类型的函数中运行.对于许多类型的错误或某些输入,仅返回一个空列表是无效的,我通常使用以下命令:
return new ArrayList<DataType>();
Run Code Online (Sandbox Code Playgroud)
这是最好的方法还是有更好的列表接口实现用于这种情况?我应该从表现的角度思考"最好"的方式.我意识到任何收获都是微不足道的,但我的强迫症方面很好奇.
在我的应用程序中使用Spring Boot:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Run Code Online (Sandbox Code Playgroud)
似乎javadoc没有与这些库捆绑在一起(这个maven是由Spring Tool Suite在创建Spring Boot项目时自动生成的),我尝试手动添加它.这会产生一些问题:
1)典型项目中有很多Spring库:spring-boot-starter-aop,spring-boot-1.5.2.RELEASE等,并且逐个添加javadoc位置将是乏味的.
2)即使我尝试在https://docs.spring.io/spring-boot/docs/current/api/添加java,我发现解析此URL时出错:" SpringApplication的未知javadoc格式... "
有没有更简单的方法在我的STS环境中获得Spring Javadoc?
我正在尝试将一个功能添加到多模块 Gradle Java 项目中(如果您好奇的话,它是 spring 集成)。我已将该项目分叉到本地计算机上,并正在创建一个单独的 Gradle 项目,该项目引用此本地克隆的项目进行开发。
在我的新项目中,settings.gradle 文件如下所示:
include ":springint"
project(":springint").projectDir = file("/users/me/git/spring-integration")
rootProject.name = 'sprinttest'
Run Code Online (Sandbox Code Playgroud)
我从我的 build.gradle 中引用它:
dependencies {
compile project(":springint")
...
Run Code Online (Sandbox Code Playgroud)
问题是它似乎只考虑 /git/spring-integration 目录的 build.gradle 而不是它的 settings.gradle。这是一个问题,因为有很多子模块是通过其 settings.gradle 文件引用的,当我运行本地项目时,这些子模块不会被拾取。我得到的错误是:
- 出了什么问题:评估项目“:springint”时出现问题。在项目“:springint”中找不到路径为“spring-integration-test-support”的项目。
如果您查看 spring-integration,settings.gradle
您会发现它动态地包含所有这些子项目:
rootProject.name = 'spring-integration'
rootDir.eachDir { dir ->
if (dir.name.startsWith('spring-integration-')) {
include ":${dir.name}"
}
}
Run Code Online (Sandbox Code Playgroud)
我认为 gradle 会在构建时自动合并此依赖项的 settings.gradle 但事实并非如此,因为这就是为什么找不到spring-integrationtest-support 的原因。我是否遗漏了某些内容,或者我应该从该项目的设置“重新创建”相同的逻辑到我自己的设置中?
我写了一堆删除语句并将它们包装在一个事务中:
start transaction;
delete a...
delete b...
delete c...
rollback;
Run Code Online (Sandbox Code Playgroud)
这个想法是我希望删除发生在完成后回滚的事务中。如果一个步骤在此过程中失败,我希望成功的步骤也能回滚。
令我懊恼的delete a
是,删除了几千行,delete b
但失败了,但是当我重新运行语句时,a 中的所有记录似乎都消失了。
这是因为交易仍处于打开状态吗?我试着做:
set session transaction isolation level read committed;
select a.*
Run Code Online (Sandbox Code Playgroud)
并返回零行,所以我认为情况并非如此。是否已a
提交成功删除?如果是这样,在我可以保证完整的工作查询之前,我如何防止这种情况发生?
我正在设置这里描述的准系统Spring Boot项目,我遇到了基本设置的问题.
似乎没有调用DatabaseLoader,当我打开这个项目的H2控制台时,我看不到包含Employee表的模式.
这是我的pom.xml的相关部分:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<!--
<scope>runtime</scope>
-->
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
我的域名:
@Data
@Entity
public class Employee {
private @Id @GeneratedValue Long id;
private String firstName;
private String lastName;
private String description;
public Employee() {}
public Employee(String firstName, String lastName, String description) {
this.firstName = firstName;
this.lastName = lastName;
this.description = description;
} …
Run Code Online (Sandbox Code Playgroud) 我们的Spring Web应用程序使用带有Quartz的Spring Batch来执行复杂的工作。这些作业大多数都在事务范围内运行,因为如果复杂系统的一部分发生故障,我们希望回滚以前的任何数据库工作。然后,我们将调查问题,部署修补程序,然后重新启动服务器。
这将成为一个问题,因为其中一些作业需要大量处理,并且可能需要很长时间才能运行。随着执行时间开始超过1小时,我们发现自己无法为其他问题部署生产修复程序,因为我们不想中断一项重要的工作。
我一直在阅读Reactor的实现,以解决我们的问题。我们可以进行少量处理,发布事件,并让其他系统根据需要执行适当的操作。甜!
我唯一的问题是,处理故障的最佳方法是什么?如果我发布事件,并且使用者无法执行某些关键功能,它将在以后重新启动吗?
如果事件已发布,并且在所有监听该事件的所有适当使用者可以正确处理该事件之前,服务器关闭了部署,该怎么办?
我一直在疯狂地试图弄清楚为什么我的脚本不能正常工作,直到我开始直接从几个网站复制和粘贴示例源代码,只是让它失败了.我的VBScripts中出现以下错误:
C:\ temp\vbs\script.vbs(19,53)Microsoft VBScript编译错误:预期语句'
对于一行代码如下:
wdoc.Application.Selection.Find.Execute Replace:=wdReplaceAll
Run Code Online (Sandbox Code Playgroud)
这与Office 2007中的Microsft Word连接以进行搜索和替换.索引53直接指向:=赋值的一部分.由于这种语法在我的机器上不起作用,我在几个网站上使用它,我想知道我使用的cscript.exe是否已过时.
我没有正确地调用cscript吗?
所以我已经完成了我的面向对象设计,将数据库模式放在一起以配合我的设计,并承诺交付截止日期不可能,我决定通过使用Web框架让我的生活更"轻松".
Spring看起来非常复杂(而且表面看起来相当不优雅)而且除了基本的CRUD应用之外,Roo在论坛上无法理解和/或获得帮助.
我正在使用(和学习!)Wicket然后完成我的任务.我花了很多时间试图弄清楚Wicket如何创建和使用数据库,如果我理解正确,它将自动从我将要创建的POJO中做到这一点.然而,我创建了以适度复杂的方式使用对象的对象,我想更好地了解最终结果在mySQL中会是什么样子.
有没有人有任何信息或链接来解释Wicket应用程序的结果架构是什么样的?
假设我有一个品牌对象列表.POJO包含一个返回字符串的getName().我想Map<String, Brand>
用String作为名称来构建一个
...但我希望密钥不区分大小写.
如何使用Java流来完成这项工作?试:
brands.stream().collect(Collectors.groupingBy(brand -> brand.getName().toLowerCase()));
Run Code Online (Sandbox Code Playgroud)
不起作用,我认为是因为我没有正确使用groupBy.
使用Eclipse和Spring Tool Suite创建调试配置时,我们可以在调试时检查测试运行后保持JUnit运行。由于我们使用SpringJUnit4ClassRunner并在运行前加载Spring应用程序,因此在这些测试可以运行之前的启动时间非常重要,因此对于重新运行测试甚至热交换基本更改而言,这可以节省大量时间。
但是,我最近切换到了IntelliJ,但找不到该功能的等效选项。有人可以告诉我它在哪里吗?
java ×6
spring ×5
eclipse ×2
annotations ×1
database ×1
frameworks ×1
gradle ×1
h2 ×1
java-8 ×1
java-stream ×1
javadoc ×1
junit ×1
list ×1
ms-office ×1
ms-word ×1
multi-module ×1
mysql ×1
spring-batch ×1
spring-boot ×1
spring-mvc ×1
vbscript ×1
wicket ×1