当type声明为string,Elasticsearch 6.0将显示此错误.
"name" => [
"type" => "string",
"analyzer" => "ik_max_word"
]
Run Code Online (Sandbox Code Playgroud) 你能否解释为什么Spring为下面显示的bean配置创建两个对象,因为默认情况下spring默认范围是singleton?
Spring配置在这里:
<bean id="customer" class="jp.ne.goo.beans.Customer">
<property name="custno" value="100"></property>
<property name="custName" value="rajasekhar"> </property>
</bean>
<bean id="customer2" class="jp.ne.goo.beans.Customer">
<property name="custno" value="200"></property>
<property name="custName" value="siva"></property>
</bean>
Run Code Online (Sandbox Code Playgroud) 我正在开发一个SpringBoot项目,我想用它的名字来获取bean applicationContext.我已尝试过很多来自网络的解决方案,但无法成功.我的要求是我有一个控制器
ControllerA
Run Code Online (Sandbox Code Playgroud)
在控制器内我有一个方法getBean(String className).我想获取已注册bean的实例.我有hibernate实体,我想通过仅在getBean方法中传递类的名称来获取bean的实例.
如果有人知道解决方案,请帮忙.
我有一个基于Spring Web模型 - 视图 - 控制器(Spring MVC 3.2.8)的应用程序,我想使用FTP SessionFactory的默认实现与FTP集成.
我有这段代码
private void performImport() throws Exception {
String fileNamePattern="*.txt";
ftpInboundFileSynchronizer = new FtpInboundFileSynchronizer(myFtpSessionFactory );
((FtpInboundFileSynchronizer) ftpInboundFileSynchronizer).setFilter(new FtpSimplePatternFileListFilter(fileNamePattern));
ftpInboundFileSynchronizer.setRemoteDirectory(remoteDirectory);
deleteLocalFiles();
System.out.println ("before synchronize");
ftpInboundFileSynchronizer.synchronizeToLocalDirectory(localDirectory);
System.out.println ("after synchronize");
}
Run Code Online (Sandbox Code Playgroud)
这是我在控制台中看到的:
before synchronize
after synchronize
Run Code Online (Sandbox Code Playgroud)
在FTP我有一个test.txt文件,但文件没有传输,我没有错误/异常
我也尝试过使用fileNamePattern="*.*";但它也不起作用
这是我的配置文件:
@Configuration
@PropertySource("classpath:/config/application.properties")
public class FtpConfiguration {
@Autowired
private SessionFactory myFtpSessionFactory;
@Bean
@Scope(value="step")
public FtpGetRemoteFilesTasklet myFtpGetRemoteFilesTasklet()
{
FtpGetRemoteFilesTasklet ftpTasklet = new FtpGetRemoteFilesTasklet();
ftpTasklet.setRetryIfNotFound(true);
ftpTasklet.setDownloadFileAttempts(3);
ftpTasklet.setRetryIntervalMilliseconds(10000);
ftpTasklet.setFileNamePattern("README");
//ftpTasklet.setFileNamePattern("TestFile");
ftpTasklet.setRemoteDirectory("/");
ftpTasklet.setLocalDirectory(new File(System.getProperty("java.io.tmpdir")));
ftpTasklet.setSessionFactory(myFtpSessionFactory);
return ftpTasklet; …Run Code Online (Sandbox Code Playgroud) 我使用JPA进行数据库访问,并使用正确的名称注释每一列.现在如果我执行查询(例如findAll())它返回
Unknown column 'program0_.program_id' in 'field list'
Run Code Online (Sandbox Code Playgroud)
错误消息是正确的program_id是未知的,因为真实姓名是programId.
型号:程序
@Entity
@Table(name = "programs")
@XmlRootElement
public class Program implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "programId")
private Long programId;
@ManyToMany
@JoinTable(
name = "programlabels",
joinColumns = {
@JoinColumn(name = "program", referencedColumnName = "programId")},
inverseJoinColumns = {
@JoinColumn(name = "label", referencedColumnName = "labelId")})
private Collection<Label> labels;
}
Run Code Online (Sandbox Code Playgroud)
标签
@Entity
@Table(name = "labels")
@XmlRootElement
public class Label implements Serializable {
@Id
@Basic(optional …Run Code Online (Sandbox Code Playgroud) 有谁知道-B maven参数的作用?样品用途:
maven clean install -B -U -e
Run Code Online (Sandbox Code Playgroud)
(我在传统的Jenkins工作配置中看到了这一点)谢谢
我正在尝试使用JSON从服务器获取一组对象.
服务器向我发送以下字符串.
"[{\"DealComment\":null,\"DealVotes\":[],\"DealId\":1,\"CompanyId\":1,\"StartDate\":\"2012-12-13T00:00:00\",\"EndDate\":\"2012-12-16T00:00:00\",\"CouponCode\":\"Test Coupon 1\",\"Description\":\"Test Deal Description 1\",\"VoteUp\":null,\"VoteDown\":null,\"ViewCount\":null,\"Title\":\"Test Deal 1\"},{\"DealComment\":null,\"DealVotes\":[],\"DealId\":2,\"CompanyId\":1,\"StartDate\":\"2012-12-16T00:00:00\",\"EndDate\":\"2012-12-17T00:00:00\",\"CouponCode\":\"Test Coupon 2\",\"Description\":\"Test Description 2\",\"VoteUp\":null,\"VoteDown\":null,\"ViewCount\":null,\"Title\":\"Test Deal 2\"},{\"DealComment\":null,\"DealVotes\":[],\"DealId\":3,\"CompanyId\":1,\"StartDate\":\"2012-12-14T00:00:00\",\"EndDate\":\"2012-12-15T00:00:00\",\"CouponCode\":\"Test Code 3\",\"Description\":\"Test Description 3\",\"VoteUp\":null,\"VoteDown\":null,\"ViewCount\":null,\"Title\":\"Test Deal 3\"},{\"DealComment\":null,\"DealVotes\":[],\"DealId\":4,\"CompanyId\":1,\"StartDate\":\"2012-12-12T00:00:00\",\"EndDate\":\"2012-12-13T00:00:00\",\"CouponCode\":\"Test Coupon 4\",\"Description\":\"Test Description 4\",\"VoteUp\":null,\"VoteDown\":null,\"ViewCount\":null,\"Title\":\"Test Deal 4\"},{\"DealComment\":null,\"DealVotes\":[],\"DealId\":5,\"CompanyId\":2,\"StartDate\":\"2012-12-12T00:00:00\",\"EndDate\":\"2012-12-14T00:00:00\",\"CouponCode\":\"AwD\",\"Description\":\"Very awesome deal!\",\"VoteUp\":null,\"VoteDown\":null,\"ViewCount\":null,\"Title\":\"Awesome Deal 1\"}]"
Run Code Online (Sandbox Code Playgroud)
现在,如果你仔细查看字符串,你会发现它包含一个\"而不是每一个".该字符串现在无法格式化为JSONArray.所以,我需要更换的每个实例\"有",这将有一个非常简单的任务,也\没有一个转义序列.
我尝试使用以下代码.
String jsonFormattedString = jsonStr.replaceAll("\\", "");
Run Code Online (Sandbox Code Playgroud)
但它给了我以下例外.
12-19 00:35:59.575: W/System.err(444): java.util.regex.PatternSyntaxException: Syntax error U_REGEX_BAD_ESCAPE_SEQUENCE near index 1:
12-19 00:35:59.575: W/System.err(444): \
12-19 00:35:59.575: W/System.err(444): ^
Run Code Online (Sandbox Code Playgroud)
我的整个代码,如果有任何用处:
public void getAllDealsFromServerJson()
{
String apiUrl = "http://passme.azurewebsites.net/api/TestApi/";
HttpClient …Run Code Online (Sandbox Code Playgroud) 使用tomcat,我有两个web应用程序,即app1和app2.我将app1以加密形式(使用下面的代码)发送到app2.然后在app2我解密了这个加密的网址.但是我在decryp方法的第50行低于例外.
"Getting javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher"
Run Code Online (Sandbox Code Playgroud)
虽然我尝试在app1解密(使用相同代码)加密的URL时进行调试,但它工作正常.但无法弄清楚在app2引起此异常的原因是什么?
这是代码
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class AESEncryptionDecryptionTest {
private static final String ALGORITHM = "AES";
private static final String myEncryptionKey = "ThisIsFoundation";
private static final String UNICODE_FORMAT = "UTF8";
public static String encrypt(String valueToEnc) throws Exception {
Key key = generateKey();
Cipher c = Cipher.getInstance(ALGORITHM);
c.init(Cipher.ENCRYPT_MODE, key);
byte[] encValue = c.doFinal(valueToEnc.getBytes());
String encryptedValue = new …Run Code Online (Sandbox Code Playgroud) 我想使用JPA从特定表中删除所有行.
我做了什么:公共类EmptyBomTables扩展了HttpServlet {
public class EmptyBomTables extends HttpServlet {
private static final long serialVersionUID = 1L;
@PersistenceContext(unitName = "xxx")
public EntityManager em;
@Resource
UserTransaction utx;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Query q1 = em.createQuery("DELETE FROM BomModule");
Query q2 = em.createQuery("DELETE FROM BomItem");
Query q3 = em.createQuery("DELETE FROM ItemModuleConnection");
Query q4 = em.createQuery("DELETE FROM ModuleConnection");
try {
utx.begin();
} catch (NotSupportedException | SystemException e) {
e.printStackTrace();
}
q1.executeUpdate(); …Run Code Online (Sandbox Code Playgroud) 我有一个tomcat实例设置,但我配置的数据库连接context.xml在一段时间不活动后仍然会死.
当我检查日志时,我收到以下错误:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:从服务器成功收到的最后一个数据包是68051秒前.成功发送到服务器的最后一个数据包是68051秒前,这比服务器配置的'wait_timeout'值长.您应该考虑在应用程序中使用之前过期和/或测试连接有效性,增加服务器配置的客户端超时值,或使用Connector/J连接属性"autoReconnect = true"来避免此问题.
这是context.xml中的配置:
<Resource name="dataSourceName"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="username"
password="********"
removeAbandoned = "true"
logAbandoned = "true"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/databasename?autoReconnect=true&useEncoding=true&characterEncoding=UTF-8" />
Run Code Online (Sandbox Code Playgroud)
我正在使用autoReconnect=true错误说要做,但连接一直在死.我以前从未见过这种情况.
我还验证了所有数据库连接都已正确关闭.
java ×8
spring ×4
database ×2
jpa ×2
command-line ×1
encryption ×1
escaping ×1
ftp ×1
hibernate ×1
jdbc ×1
maven ×1
mysql ×1
regex ×1
replace ×1
singleton ×1
spring-boot ×1
spring-ioc ×1
string ×1
tomcat ×1