简体   繁体   中英

IntelliJ IDEA why I don't see the method in import dialog? (have in project and if put with copy-past to class, it's accessible). Maven+Java project

I use 15.0.4 IDEA Coomunity edtition (same trouble was for at least for 2 versions). Actually, I clicked something wrong and need help. :-) So... In pom.xml I have in list of my dependencies:

<dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-all</artifactId> <version>1.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.exparity</groupId> <artifactId>hamcrest-date</artifactId> <version>1.1.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency>

And when I add in any method someting like that:

AssertThat(%someVariable%,is("someExpectedValue"))

And tries to auto-import there are only possibilities to auto-import from org.junit. But if I add

import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is;

The assertion code works correctly. So, the problem is: my auto-import in IDEA don't offer to import hamcrest classes (before it worked, and I guess there are some settings or project properties issue...).

ps code completion does not work for assertThat (hamcrest) too. Instead of it i got a lot of SeleneseTestBase.assert%%.

Go to Settings > Editor > Code Style > Java then select Imports. There you can set static imports

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM