AS AgentScopeAPI 手册 / API Reference

JpaPersistenceConfig

@Configuration @EnableJpaRepositories(basePackageClasses = JpaPersistenceConfig.class) @EntityScan(basePackageClasses = JpaPersistenceConfig.class) @EnableTransactionManagement public class JpaPersistenceConfig
源码Source io/agentscope/builder/web/persistence/jpa/JpaPersistenceConfig.java:60–87

JPA 持久化配置,保存相关配置项。位于 io.agentscope.builder.web.persistence.jpa 包。核心成员包括 transactionTemplate、jpaUserStore、jpaUserAgentDefinitionStore。

Wires the JPA-backed UserStore and UserAgentDefinitionStore. This is the only persistence backend the builder ships with.

Default DataSource

The default application.yml points spring.datasource.url at an embedded H2 file under ${user.home}/.agentscope-builder/db — kept deliberately separate from builder.workspace so workspace volumes never include the catalog tables. No external services or extra setup are required for a single-node deployment.

Switching to MySQL / PostgreSQL

Activate the bundled jdbc Spring profile to flip the DataSource defaults to MySQL-shaped values:

`--spring.profiles.active=jdbc

# Or override individual settings without the profile:
BUILDER_DB_URL=jdbc:postgresql://host:5432/agentscope_builder
BUILDER_DB_DRIVER=org.postgresql.Driver
BUILDER_DB_USER=...
BUILDER_DB_PASSWORD=...
BUILDER_JPA_DDL_AUTO=validate # once Flyway / Liquibase manage the schema
`

The MySQL (com.mysql:mysql-connector-j) and PostgreSQL (org.postgresql:postgresql) JDBC drivers are bundled at runtime scope; the active Hibernate dialect is resolved from the spring.datasource.url.

方法摘要Method Summary

方法Method说明Description
public org.springframework.transaction.support.TransactionTemplate transactionTemplate(org.springframework.transaction.PlatformTransactionManager txManager)
设置事务模板。
Performs the transaction template operation.
public UserStore jpaUserStore(UserEntityRepository repository, boolean seedUsers)
执行JPA 用户存储相关操作。
Performs the jpa user store operation.
public UserAgentDefinitionStore jpaUserAgentDefinitionStore(AgentEntityRepository repository)
设置JPA 用户智能体定义存储。
Performs the jpa user agent definition store operation.

方法详情Method Detail

transactionTemplate

public org.springframework.transaction.support.TransactionTemplate transactionTemplate(org.springframework.transaction.PlatformTransactionManager txManager)

设置事务模板。

Performs the transaction template operation.

参数Parameters
名称Name类型Type说明Description
txManagerorg.springframework.transaction.PlatformTransactionManagertx 管理器(类型 `org.springframework.transaction.PlatformTransactionManager`)。The tx manager.
返回Returns org.springframework.transaction.support.TransactionTemplate
返回org.springframework.事务.support.TransactionTemplate。Returns org springframework transaction support transaction template.
源码Source io/agentscope/builder/web/persistence/jpa/JpaPersistenceConfig.java:68–72

jpaUserStore

public UserStore jpaUserStore(UserEntityRepository repository, boolean seedUsers)

执行JPA 用户存储相关操作。

Performs the jpa user store operation.

参数Parameters
名称Name类型Type说明Description
repositoryUserEntityRepository仓库(类型 `UserEntityRepository`)。The repository.
seedUsersboolean预置用户(类型 `boolean`)。The seed users.
返回Returns UserStore
返回UserStore。Returns user store.
源码Source io/agentscope/builder/web/persistence/jpa/JpaPersistenceConfig.java:74–80

jpaUserAgentDefinitionStore

public UserAgentDefinitionStore jpaUserAgentDefinitionStore(AgentEntityRepository repository)

设置JPA 用户智能体定义存储。

Performs the jpa user agent definition store operation.

参数Parameters
名称Name类型Type说明Description
repositoryAgentEntityRepository仓库(类型 `AgentEntityRepository`)。The repository.
返回Returns UserAgentDefinitionStore
返回UserAgentDefinitionStore。Returns user agent definition store.
源码Source io/agentscope/builder/web/persistence/jpa/JpaPersistenceConfig.java:82–86
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.