这是一个32位的Ubuntu操作系统
rob@laptop:~$ uname -a
Linux laptop 3.5.0-37-generic #58~precise1-Ubuntu SMP Wed Jul
10 17:51:56 UTC 2013 i686 i686 i386 GNU/Linux
rob@laptop:~$ java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK Server VM (build 23.7-b01, mixed mode)
rob@laptop:~$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
0 /usr/lib/j2re1.6-ibm/jre/bin/java 1200 auto mode
1 /home/rob/Downloads/jre1.7.0_25/bin/java 1 manual mode
2 /usr/lib/j2re1.6-ibm/jre/bin/java 1200 manual mode
* 3 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1051 manual mode
Run Code Online (Sandbox Code Playgroud)
我希望能够运行超过2g的堆
rob@laptop:~$ …Run Code Online (Sandbox Code Playgroud) 我已经编写了一个 angular 4 应用程序,现在我正在尝试使用Protractor.
我在这里错过了什么吗?
尝试运行测试脚本时出错:
[rob@work repo]$ npm run e2e
> repo@1.0.0 e2e /home/rob/git/repo
> protractor protractor.config.js
[20:12:24] I/launcher - Running 1 instances of WebDriver
[20:12:24] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[20:12:25] E/launcher - Error: /home/rob/git/repo/test/e2e/app.ui.test.ts:3
import { browser } from 'protractor';
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /home/rob/git/repo/node_modules/jasmine/lib/jasmine.js:93:5
at …Run Code Online (Sandbox Code Playgroud) 我的目标是使用内存数据库进行这些单元测试,这些依赖项列出为:
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
runtimeOnly("com.h2database:h2")
Run Code Online (Sandbox Code Playgroud)
这样存储库实例实际上与数据库交互,并且我不只是模拟返回值。
问题是,当我运行单元测试时,服务实例内的存储库实例是null.
这是为什么?我是否缺少单元测试类上的一些注释来初始化存储库实例?
这是运行我的单元测试时的控制台输出:
null
java.lang.NullPointerException
at com.my.MyService.findAll(MyService.java:20)
at com.my.MyTest.testMy(MyTest.java:23)
Run Code Online (Sandbox Code Playgroud)
我的单元测试课:
public class MyTest {
@MockBean
MyRepository myRepository;
@Test
void testMy() {
MyService myService = new MyService();
int size = myService.findAll().size();
Assertions.assertEquals(0, size);
}
}
Run Code Online (Sandbox Code Playgroud)
我的服务等级:
@Service
public class MyService {
@Autowired
MyRepository myRepository;
public List<MyEntity> findAll() {
System.out.println(myRepository); // null
return (List<MyEntity>) myRepository.findAll(); // throws NullPointerException
}
@Transactional
public MyEntity create(MyEntity myEntity) {
myRepository.save(myEntity);
return myEntity;
}
}
Run Code Online (Sandbox Code Playgroud)
我的存储库类:
@Repository
public interface MyRepository extends …Run Code Online (Sandbox Code Playgroud) 任何人都知道为什么width:xx%桌面上的每个细胞都没有被使用?
看起来第一行可能设置正确,但第二行的大小被忽略.
http://jsfiddle.net/bobbyrne01/4fLL8md0/1/
<table>
<tr>
<td style="width:80%;">A lot of text on 1 line</td>
<td style="width:20%">Text</td>
</tr>
<tr>
<td style="width:20%">
<label>Directory:</label>
</td>
<td style="width:80%">
<input id="directory" readonly="true" />
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)

我有一个 POJO,其中包含一个名为price.
该字段的类型是javax.money.MonetaryAmount,以便我可以从 JSR 354 验证等中受益。
我对该字段有一个限制,指定货币必须是EUR:
@Currency("EUR")
Run Code Online (Sandbox Code Playgroud)
如何指定货币必须是EUR或USD?
import org.hibernate.annotations.Columns;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.validator.constraints.Currency;
import org.jadira.usertype.moneyandcurrency.moneta.PersistentMoneyAmountAndCurrency;
import javax.money.MonetaryAmount;
import javax.persistence.*;
@Entity
@TypeDef(name = "persistentMoneyAmountAndCurrency", typeClass = PersistentMoneyAmountAndCurrency.class)
public class LocalizedProduct {
@Id
@GeneratedValue
private long id;
@Currency("EUR")
// @Currency("EUR, USD") .. doesn't work
@Columns(columns = {
@Column(name = "amount_currency", length = 3),
@Column(name = "amount_value", precision = 19, scale = 5)})
@Type(type = "persistentMoneyAmountAndCurrency")
private MonetaryAmount price; …Run Code Online (Sandbox Code Playgroud) java ×3
angular ×1
css ×1
heap ×1
html ×1
html-table ×1
java-money ×1
jpa ×1
jsr354 ×1
jvm ×1
protractor ×1
spring ×1
spring-boot ×1
typescript ×1
unit-testing ×1
validation ×1