<div>
<p>This is a sample text.</p>
<p>This is a 2nd sample text. existing inside a paragraph. I want to make this ellipsis to avoid overflow text.</p>
<p>This is a last paragraph which is not going to display as 3 lines are already displayed</p>
</div>
Run Code Online (Sandbox Code Playgroud)
所需输出 -
This is a sample text.
This is a 2nd sample text. existing
inside a paragraph. I want to make...
Run Code Online (Sandbox Code Playgroud)
我想通过将所有段落视为单个文本,在 div 省略号内制作 3 行文本。
我怎样才能实现这个目标?
我尝试过以下一种 -
<div>
<p>This is a sample text.</p>
<p>This …Run Code Online (Sandbox Code Playgroud)我想在 spring boot+ JPA 中执行单元测试。为此,我创建了配置文件来为 dataSource、所有 hibernate 属性、entityManagerFactory 和 transactionManager 创建 bean。一切都很完美。表是由模型类创建的。但现在我想通过data.sql文件在数据库的所有表中插入数据进行测试。我将 data.sql 文件保留在 src/main/resources 中,但它没有加载该文件。那么在开始单元测试之前如何在 h2 数据库中加载数据。
这是我的配置文件 -
import java.util.Properties;
import javax.sql.DataSource;
import org.hibernate.cfg.Environment;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableJpaRepositories(basePackages = "base_package_name")
@EnableTransactionManagement
public class JPAConfig {
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUrl("jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1");
/*dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
dataSource.setUrl("jdbc:hsqldb:mem:testdb");*/
dataSource.setUsername("sa");
dataSource.setPassword("");
return dataSource;
} …Run Code Online (Sandbox Code Playgroud)