web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>springsecuritydemo</display-name>
<!-- <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> -->
<servlet>
<description></description>
<display-name>offers</display-name>
<servlet-name>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/DispatcherServlet</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
报价-sevlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:context = "http://www.springframework.org/schema/context"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation = "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.spring.security.web"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<bean name="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
这有什么不对?我无法访问home.jsp.我实际上是在春季3.0观看教程,我已经完成了视频中的显示.谁能在这里指出我的错误?
我有这个hibernate dao,它在我的本地机器上测试时工作正常.但对于某些事务,它会抛出IllegalStateException.我相信这是因为多个用户同时打.(我可能错了).
UpdatePaymentDao
@Repository公共类UpdatePaymentImpl实现UpdatePayment {
@Repository
public class UpdatePaymentImpl implements UpdatePayment {
@Autowired
SessionFactory sessionFactory;
Session session;
Transaction trans;
private static final long LIMIT = 100000000000L;
private static final long LIMIT2 = 10000000000L;
private static long last = 0;
public static long getUniqueID() {
// 10 digits.
long id = (System.currentTimeMillis() % LIMIT) + LIMIT2;
System.out.println("id"+id);
System.out.println("system time"+System.currentTimeMillis());
System.out.println("milssiiiiii=============="
+ System.currentTimeMillis());
if (id <= last) {
id = (last + 1) % LIMIT;
}
return last = id;
}
public …
Run Code Online (Sandbox Code Playgroud) 我有一张桌子。
如您所见, created_date 列是时间戳字段。现在选择我只想考虑日期值。例如,如果我想从今天开始选择行,我想做以下事情:-
select * from audit_logs where created_date = '2018-11-28';
Run Code Online (Sandbox Code Playgroud)
上面的查询返回 null。可以这样选择吗?
我正在尝试使用 postgres 数据库设置 Spring Boot 项目。我的实体是:-
用户
@Entity
public class User implements UserDetails {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id", nullable = false, updatable = false)
private Long id;
private String username;
private String password;
private String firstName;
private String lastName;
@Column(name="email", nullable = false, updatable = false)
private String email;
private String phone;
private boolean enabled=true;
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JsonIgnore
private Set<UserRole> userRoles = new HashSet<>();
public Long getId() {
return id;
}
public void setId(Long …
Run Code Online (Sandbox Code Playgroud) 我在做简单的测试。
@Test
public void whenFilterEmployees_thenGetFilteredEmployees(){
Integer[] empIds = {1,2,3};
List<Optional<Employee>> employees = Stream.of(empIds)
.map(employeeRepository::findById)
.collect(Collectors.toList());
List<Employee> employeeList = employees
.stream().filter(Optional::isPresent)
.map(Optional::get)
.filter(e->e !=null)
.filter(e->e.getSalary()>200000)
.collect(Collectors.toList());
assertEquals(Arrays.asList(arrayOfEmps[2]), employeeList);
}
Run Code Online (Sandbox Code Playgroud)
我的员工表包含数据:
1 Jeff Bezos 100000
2 Bill Gates 200000
3 Mark Zuckerberg 300000
Run Code Online (Sandbox Code Playgroud)
当前测试成功运行。
如您所见,我准备了两个员工列表,即员工和员工列表
我这样做是因为findById
方法返回 Optional。我如何使用流 api 以便我可以简单地获取员工列表
List<Employee> employeeList= ....
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用3.0.7.RELEASE
基于spring mvc java的配置的thymeleaf .
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.sagar")
public class MvcConfig extends WebMvcConfigurerAdapter implements ApplicationContextAware{
@Autowired
RoleToUserProfileConverter roleToUserProfileConverter;
private ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@Bean
public ViewResolver viewResolver() {
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
resolver.setCharacterEncoding("UTF-8");
return resolver;
}
@Bean
public TemplateEngine templateEngine() {
SpringTemplateEngine engine = new SpringTemplateEngine();
engine.setEnableSpringELCompiler(true);
engine.setTemplateResolver(templateResolver());
return engine;
}
private ITemplateResolver templateResolver() {
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
resolver.setApplicationContext(applicationContext);
resolver.setPrefix("/WEB-INF/templates/");
resolver.setTemplateMode(TemplateMode.HTML);
return resolver;
}
public void …
Run Code Online (Sandbox Code Playgroud) 我正在尝试打包我的spring boot应用程序,以便可以将其部署在tomcat服务器上。观看完youtube视频后,我扩展了SpringBootServletInitializer类并进行了一些更改。
@ComponentScan("com.infodev.loksewa")
@SpringBootApplication
public class LoksewaApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(LoksewaApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(LoksewaApplication.class);
}
}
Run Code Online (Sandbox Code Playgroud)
pox.xml
<?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>
<groupId>com.infodev</groupId>
<artifactId>loksewa</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>loksewa</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<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-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency> …
Run Code Online (Sandbox Code Playgroud) 每当我在html文件上更改某些内容时,我必须重新启动整个项目.我试过了:-
- >编辑配置 - >服务器并更改帧检测以更新资源.
在我的服务器选项卡上,还有关于帧检测的更新资源.但仍然无法更新我的html文件,我必须重新启动服务器以反映我的更改.
Intellij Idea版本是2017年.
我必须上课
public class Consumer{
private String name;
private int salary;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
}
Run Code Online (Sandbox Code Playgroud)
接下来
public class Donor {
private String name;
private int amount;
private String location;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAmount() {
return amount;
} …
Run Code Online (Sandbox Code Playgroud) java ×6
spring ×3
postgresql ×2
spring-boot ×2
thymeleaf ×2
hibernate ×1
java-stream ×1
oracle ×1
sql ×1