我在推送 git 时遇到问题。显示此错误消息:
SSL certificate problem: unable to get local issuer certificate
Run Code Online (Sandbox Code Playgroud) 我有这段代码,我想重构Java 8
List<String> menus = new ArrayList<String>();
for (Menu menu : resto1.getMenu()) {
MainIngredient mainIngredient = MainIngredient.getMainIngredient(menu.getName());
if (mainIngredient.getIngredient().indexOf("Vegan")!=-1) {
menus.add(menu.getName());
}
}
Run Code Online (Sandbox Code Playgroud)
重构这个简单的循环之后,似乎代码太多......我是否正确使用CompletableFutures?
ExecutorService executorService = Executors.newCachedThreadPool();
List<CompletableFuture<MainIngredient>> priceFutureList = resto1.getMenu().stream()
.map(menu -> CompletableFuture.supplyAsync(
() -> MainIngredient.getMainIngredient(menu.getName()), executorService))
.collect(Collectors.toList());
CompletableFuture<Void> allFuturesDone = CompletableFuture.allOf(
priceFutureList.toArray(new CompletableFuture[priceFutureList.size()]));
CompletableFuture<List<MainIngredient>> priceListFuture =
allFuturesDone.thenApply(v -> priceFutureList.stream()
.map(CompletableFuture::join)
.collect(toList()));
Run Code Online (Sandbox Code Playgroud) 我有一个SpringBoot 2.1.4.RELEASE RESTful Web Service应用程序,它使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎以及作为可执行JAR文件的软件包。我正在使用inMemoryDatabase:H2数据库引擎
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我有这些对象:
@Entity
@Table(name="t_menu_alert_notification")
public class MenuAlertNotification implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@JsonProperty("id")
private Long id;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REMOVE)
@JoinColumn(name = "menu_alert_id")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="name")
@JsonIdentityReference(alwaysAsId=true)
protected MenuAlert menuAlert;
...
}
@Entity
@Table(name="t_menu_alert")
public class MenuAlert implements Serializable {
public MenuAlert() {
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "menu_id")
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="name")
@JsonIdentityReference(alwaysAsId=true)
Menu menu;
..
}
@Entity
@Table(name = "t_menu")
@JsonPropertyOrder({ "id", "name", "address", "description" }) …Run Code Online (Sandbox Code Playgroud) 我已将Maven项目导入到Eclipse版本:2018-09(4.9.0)中,但pom文件中出现此错误。我在另一台计算机上已经有相同的项目,并且工作正常。该项目是springBoot 2.0.6.RELEASE
Project build error: Non-resolvable parent POM for es.teatreDeGuerrila:teatreDeGuerrilaCloudApp:1.0.0-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.6.RELEASE from
https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error:
Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.6.RELEASE from/to central (https://repo.maven.apache.org/maven2): connect timed out and
'parent.relativePath' points at no local POM
Run Code Online (Sandbox Code Playgroud)
而且我在类中有很多编译错误,例如
The import org.springframework cannot be resolved
Run Code Online (Sandbox Code Playgroud)
从命令行使用mvn install -Dmaven.test.skip=true,一切正常。
并且我已经在Eclipse中将其作为Manual在Proxy中进行了设置,与文件中的设置相同 ../maven/conf/settings.xml
<proxy>
<id>httpproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.teatre.guerrila.int</host>
<port>8080</port>
<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts> …Run Code Online (Sandbox Code Playgroud) 我是 Java8 新手,我创建了这段运行良好的代码
userService.getClient().findUsersByMarkets(marketIds)
.stream()
.filter(us -> !alreadyNotifiedUserIds.contains(us.getId()))
.forEach(usersToBeNotified::add);
Run Code Online (Sandbox Code Playgroud)
但根据我的理解,这段代码也应该可以正常工作,但事实并非如此,我想知道为什么
userService.getClient().findUsersByMarkets(marketIds)
.stream()
.filter(us -> !alreadyNotifiedUserIds.contains(User::getId))
.forEach(usersToBeNotified::add);
Run Code Online (Sandbox Code Playgroud) 我有这段代码
List<BookDto> deskOfficer =
delegationExtendedDto
.stream()
.filter(Objects::nonNull)
.filter(d -> d.getMembers() !=null && !d.getMembers().isEmpty())
.map(d -> d.getMembers()
.stream()
.filter(Objects::nonNull)
.filter(m -> RolesEnum.RESPONSIBLE_ADMIN.equals(m.getRole())))
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
但我有一个编译错误
Type mismatch: cannot convert from List<Stream<BookDto>> to List<BookDto>
Run Code Online (Sandbox Code Playgroud) 我有一个SpringBoot 2.1.4.RELEASE RESTful Web Service应用程序,它使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎以及作为可执行JAR文件的软件包。
我的其中一个模板中有这段代码,
<tr th:each="menuPriceSummary: ${menus}" >
...
<a href="#" th:onclick="|changeAIColor('idAwesomeIconFAV${menuPriceSummary.menu.symbol}');| + 'performAjaxCall(\'' + @{/allmenupricesummary/switchfav/{id}(id=${menuPriceSummary.menu.symbol})} + '\');'" >
<span th:if="${menuPriceSummary.favorited}">
<i th:id="'idAwesomeIconFAV'+${menuPriceSummary.menu.symbol}" class="fa fa-toggle-on fa-lg" style="color:#009900; text-align: center;" aria-hidden="true"></i>
</span>
<span th:if="${!menuPriceSummary.favorited}">
<i th:id="'idAwesomeIconFAV'+${menuPriceSummary.menu.symbol}" class="fa fa-toggle-off fa-lg" style="color:#e6e6e6;" aria-hidden="true"></i>
</span>
</a>
</tr>
Run Code Online (Sandbox Code Playgroud)
但是在渲染模板时出现此错误:
org.thymeleaf.exceptions.TemplateProcessingException: Only variable expressions returning numbers or booleans are allowed in this context, any other datatypes are not trusted in the context of this expression, including Strings or any other object that could …Run Code Online (Sandbox Code Playgroud) 我是Java8的新手,我想重构这段代码并将其转换为更多的Java8风格,
for (RestaurantAddressee RestaurantAddressee : consultationRestaurant.getAddressees()) {
Chain chain = chainRestService.getClient().getChainDetails(getTDKUser(), RestaurantAddressee.getChain().getId());
if (chain.getOrganisation().getId().equalsIgnoreCase(event.getOrganisationId())) {
chainIds.add(restaurantAddressee.getChain().getId());
}
}
Run Code Online (Sandbox Code Playgroud)
所以我为这段代码改了:
consultationRestaurant.getAddressees()
.stream()
.map( ma -> chainRestService.getClient().getChainDetails(getTDKUser(), ma.getChain().getId()))
.filter(chain -> chain.getOrganisation().getId().equalsIgnoreCase(event.getOrganisationId()))
.forEach(chainIds.add(chain.getId()));
Run Code Online (Sandbox Code Playgroud)
但我有这个编译错误:
链无法解决
我有这段代码,我想使用更多的Java 8方法进行重构,但我知道有几个选项可以做到这一点:concat()Java 8 Stream API,flatMap()Java 8 Stream API,使用Guava,使用Apache Commons Collections,CompletableFuture ....我想知道是否有最好的做法来做到这一点
List<User> users = new ArrayList<User>();
for (Restaurant restaurant : restaurants) {
users.addAll(userService.getClients(restaurant.getId())
.parallelStream()
.filter(us -> !alreadyNotifiedUserIds.contains(us.getId())))
.collect(Collectors.toList());
}
Run Code Online (Sandbox Code Playgroud) 我有这段代码
List<UserNotification> userNotifications = new ArrayList<UserNotification>();
teatreAlertNotifications
.parallelStream()
.forEach(can -> userNotifications.add(new UserNotification(can)));
Run Code Online (Sandbox Code Playgroud)
但由于ArrayList是不同步的,我认为这是不好的做法,我应该使用.stream()代替
parallel-processing functional-programming java-8 java-stream
我有一个 SpringBoot 2.1.4.RELEASE RESTful Web 服务应用程序,使用 Spring Initializer、嵌入式 Tomcat、Thymeleaf 模板引擎,并打包为可执行 JAR 文件。
我有这个配置文件:
@Profile("dev")
@Configuration
@EnableWebSecurity
public class DevWebSecurityConfig extends WebSecurityConfigurerAdapter {
private static final Logger LOG = LoggerFactory.getLogger(DevWebSecurityConfig.class);
@Autowired
private UserSecurityService userSecurityService;
@Autowired
private Environment env;
@Value("${server.servlet.context-path}")
private String serverContextPath;
/** The encryption SALT. */
private static final String SALT = "12323*&^%of";
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(12, new SecureRandom(SALT.getBytes()));
}
@Override
protected void configure(HttpSecurity http) throws Exception {
final List<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
if (activeProfiles.contains("dev")) { …Run Code Online (Sandbox Code Playgroud) spring spring-security bcrypt spring-boot spring-security-oauth2
我想结帐一个分支,我收到了这条消息
error: Your local changes to the following files would be overwritten by checkout:
src/main/webapp/data/GuerrillaLabels.json
Please, commit your changes or stash them before you can switch branches.
Aborting
Run Code Online (Sandbox Code Playgroud)
但我希望这些文件被覆盖
java-8 ×6
java-stream ×6
java ×5
spring-boot ×4
git ×2
spring-mvc ×2
bcrypt ×1
eclipse ×1
html ×1
http-proxy ×1
jpa ×1
maven ×1
proxy ×1
spring ×1
spring-data ×1
thymeleaf ×1