我正在遵循本指南:https : //spring.io/guides/gs/serving-web-content/,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/>
</parent>
<groupId>org.example</groupId>
<artifactId>plats-bruts</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
但我在 pom 上有这个问题:
Project 'org.springframework.boot:spring-boot-starter-parent:2.4.0' not found
Run Code Online (Sandbox Code Playgroud)
但它在这里https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent/2.4.0
我是新手Java8,我想知道,对于AutoCloseable资源,我是否必须try为每个添加一个resource,或者它将使用上面的代码
try (Connection conn = getConnection();) {
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(sql);
while (rset.next()) {
TelefonicaDataVO vo = new TelefonicaDataVO();
vo.setTelefonicaDataId(rset.getString("Telefonica_PSD_ID"));
vo.setReceptionDate(nvl(rset.getTimestamp("CREATION_DATE")));
vo.setMessage(nvl(rset.getString("MESSAGE")));
ret.add(vo);
}
}
Run Code Online (Sandbox Code Playgroud) 我使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎和包作为可执行JAR文件生成了一个Spring Boot Web应用程序.
使用的技术:
Spring Boot 2.0.0.M6,Java 8,maven
我在这个课程中有一个这个方法
private Map<String, Object> getErrorAttributes(HttpServletRequest request,
boolean includeStackTrace) {
RequestAttributes requestAttributes = new ServletRequestAttributes(request);
return this.errorAttributes.getErrorAttributes(request, includeStackTrace)
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何施展 javax.servlet.http HttpServletRequest org.springframework.web.context.request.WebRequest
The method getErrorAttributes(WebRequest, boolean) in the type ErrorAttributes is not applicable for the arguments (HttpServletRequest,
boolean)
Run Code Online (Sandbox Code Playgroud) 我有几个oracle程序:
create or replace procedure receive_sms (p_to_date in date)
is
..
end;
Run Code Online (Sandbox Code Playgroud)
和
create or replace procedure send_sms (p_date in date)
is
..
end;
Run Code Online (Sandbox Code Playgroud)
我想基于这些程序创建一个链,并为链和一些规则添加步骤:
BEGIN
DBMS_SCHEDULER.CREATE_CHAIN (
chain_name => 'mobile_archive_chain',
rule_set_name => NULL,
evaluation_interval => NULL,
comments => NULL);
END;
/
--- define three steps for this chain. Referenced programs must be enabled.
BEGIN
DBMS_SCHEDULER.DEFINE_CHAIN_STEP('mobile_archive_chain', 'send', 'inforpilla.send_sms');
DBMS_SCHEDULER.DEFINE_CHAIN_STEP('mobile_archive_chain', 'receive', 'inforpilla.receive_sms');
END;
/
--- define corresponding rules for the chain.
BEGIN
DBMS_SCHEDULER.DEFINE_CHAIN_RULE ('mobile_archive_chain', 'TRUE', 'START send');
DBMS_SCHEDULER.DEFINE_CHAIN_RULE ('mobile_archive_chain', 'send COMPLETED', …Run Code Online (Sandbox Code Playgroud) 我刚刚创建了一个具有此依赖项的 Maven 项目
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但我意识到所有这些类都没有找到:
import javax.persistence.*
Run Code Online (Sandbox Code Playgroud)
所以我必须将依赖项更改为
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我觉得很奇怪,因为上次更新来自Aug 21, 2017
没有包含 javax.persistence 的 spring 依赖项???
我是GlassFish Server和WS的新手.我刚刚部署了一个Web应用程序.使用具有此web.xml的maven生成
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
Run Code Online (Sandbox Code Playgroud)
我单击Web应用程序链接
我在应用程序中有这个类:
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.servlet.http.HttpSession;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
@WebService(serviceName="IberiaWS")
public class IberiaWS {
@Resource
private WebServiceContext wsContext;
public IberiaWS () {
}
private UserVO getSessionUserVO() {
MessageContext mc = wsContext.getMessageContext();
HttpSession session = ((javax.servlet.http.HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getSession();
return (UserVO)session.getAttribute("uservo");
}
private void setSessionUserVO(UserVO uservo) {
MessageContext mc = wsContext.getMessageContext();
HttpSession session = ((javax.servlet.http.HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getSession();
session.setAttribute("uservo", uservo);
}
@WebMethod
public boolean …Run Code Online (Sandbox Code Playgroud) 我正在从主类访问资源文件夹内的文件
File file = new ClassPathResource("remoteUnitsIdsInOldServer.txt").getFile();
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
java.io.FileNotFoundException: class path resource [remoteUnitsIdsInOldServer.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/Users/lopes/Documents/workspace-sts-3.9.0.RELEASE/telefonicaUtils/target/telefonicaUtils-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/remoteUnitsIdsInOldServer.txt
Run Code Online (Sandbox Code Playgroud)
我什至打开 jar 文件,文件 remoteUnitsIdsInOldServer.txt 就在那里,在类内部
我有一个 SpringBoot 应用程序。
我创建了这个测试:
@ContextConfiguration(classes={TestConfig.class})
@RunWith(SpringRunner.class)
@SpringBootTest
public class SuncionServiceITTest {
@Test
public void should_Find_2() {
// TODO
}
}
Run Code Online (Sandbox Code Playgroud)
在哪里
@Configuration
@EnableJpaRepositories(basePackages = "com.plats.bruts.repository")
@PropertySource("local-configuration.properties")
@EnableTransactionManagement
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class TestConfig {
}
Run Code Online (Sandbox Code Playgroud)
和本地configuration.properties:
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
spring.datasource.username=sa
spring.datasource.password=sa
Run Code Online (Sandbox Code Playgroud)
但是当我运行测试时。我收到此错误:
引起:org.springframework.beans.factory.NoSuchBeanDefinitionException:没有名为“entityManagerFactory”的bean可用
我也试过:
@EnableJpaRepositories(basePackages = "com.plats.bruts.repository", entityManagerFactoryRef="emf")
Run Code Online (Sandbox Code Playgroud)
但后来我有错误:
引起:org.springframework.beans.factory.NoSuchBeanDefinitionException:没有可用的名为“emf”的bean
如何获取 thymeleaf 模板中的当前区域设置?
我试过了
<html xmlns:th="http://www.thymeleaf.org" lang="${#locale}" xml:lang="${#locale}" class="no-js">
Run Code Online (Sandbox Code Playgroud)
和
<html xmlns:th="http://www.thymeleaf.org" lang="${request.locale}" xml:lang="${request.locale}" class="no-js">
Run Code Online (Sandbox Code Playgroud)
但两者都不起作用
我想创建一个Oracle DBMS作业,每10分钟从09:00到20:00每周(不是在周末)运行.我想知道我是否可以FREQ在作业定义的参数中执行此操作,或者我必须创建一个New Maintenance Window.
似乎在提出的解决方案中,作业仅在9和20运行,并且在第一次执行后,当我运行此查询时
select owner, job_name, next_run_date
from dba_scheduler_jobs
where JOB_NAME = 'GET_INVOICES_JOB';
Run Code Online (Sandbox Code Playgroud)
我有 09/10/17 20:01:27,000000000 EUROPE/MADRID
'freq=minutely; interval=10; byhour=9,20; byday=MON,TUE,WED,THU,FRI; exclude=Company_Holidays; bysetpos=-1'
Run Code Online (Sandbox Code Playgroud) java ×8
spring-boot ×6
spring ×4
oracle ×2
oracle11g ×2
spring-data ×2
file-io ×1
glassfish ×1
h2 ×1
html ×1
jax-ws ×1
jobs ×1
jpa ×1
maven ×1
plsql ×1
pom.xml ×1
spring-mvc ×1
thymeleaf ×1
web-services ×1